Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not produce let as a variable name in mangle. #1011

Merged
merged 2 commits into from
Mar 24, 2016
Merged

Do not produce let as a variable name in mangle. #1011

merged 2 commits into from
Mar 24, 2016

Conversation

kzc
Copy link
Contributor

@kzc kzc commented Mar 15, 2016

Fixes #986 based on patch originally provided by @pablocubico.
Bug would previously occur in large generated functions with 21,000+ variables.
May have also happened with emscripten asm.js output.

kzc added 2 commits March 15, 2016 11:20
Would previously occur in large generated functions with 21,000+ variables.
Fixes #986.

// Produce a lot of variables in a function and run it through mangle.
var s = '"use strict"; function foo() {';
for (var i = 0; i < 21000; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only 21e3? Should be Math.pow(64, 3) + Math.pow(64, 2) + 64 or 266304.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it takes too long to test. On my machine the mangle test for 21,000 variables is 1 second, but on Travis CI machine it is over 2 seconds. 266K vars would take around 24s or so on Travis CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test looks for the symbols that had existed before and after the erroneously generated let. If the mangle algorithm changes, this test would have to be updated.

But if @mishoo or @rvanvelzen would be good with a 50 second npm test (2X estimated Travis CI run time) to test all 3 letter mangle var names, then we could do that.

Edit: node 5.8.0 cannot handle running an uglifyjs mangle against a function with more than 126,000 variables - Maximum call stack size exceeded. So that's a no go.

@kzc
Copy link
Contributor Author

kzc commented Mar 24, 2016

@mishoo or @rvanvelzen Could you please commit this obvious one line bug fix?

@mishoo mishoo merged commit f68de86 into mishoo:master Mar 24, 2016
@mishoo
Copy link
Owner

mishoo commented Mar 24, 2016

I'd be OK with no test here. I'm not the guy to believe that every fix should be accompanied by a test case. Some bugs, once fixed, will stay fixed — there's no reason why someone would later remove let from the list of keywords.

Any case, it runs in like one second here, it's acceptable. Definitely let's not increase that.

@pablocubico
Copy link

@kzc @mishoo Great.

@kzc
Copy link
Contributor Author

kzc commented Mar 24, 2016

@mishoo - I agree this test is over the top. I just wanted to prove to myself that it worked in a non-API-changing intrusive manner. I'll submit a PR to remove the test.

@mishoo
Copy link
Owner

mishoo commented Mar 24, 2016

@kzc no no, just leave it, it's fine. Just wanted to say that as far as I am concerned, you need not stress too much about tests.

@kzc kzc deleted the dont-produce-let-in-mangle branch November 21, 2018 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants