Do not produce let as a variable name in mangle.

Would previously occur in large generated functions with 21,000+ variables.
Fixes #986.
This commit is contained in:
kzc
2016-03-15 11:20:32 -04:00
parent ee6c9fabb7
commit a9d4a6291b
2 changed files with 27 additions and 1 deletions

26
test/mocha/let.js Normal file
View File

@@ -0,0 +1,26 @@
var Uglify = require('../../');
var assert = require("assert");
describe("let", function() {
it("Should not produce `let` as a variable name in mangle", function() {
// 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) {
s += "var v" + i + "=0;";
}
s += '}';
var result = Uglify.minify(s, {fromString: true, compress: false});
// Verify that select keywords and reserved keywords not produced
assert.strictEqual(result.code.indexOf("var let="), -1);
assert.strictEqual(result.code.indexOf("var do="), -1);
assert.strictEqual(result.code.indexOf("var var="), -1);
// Verify that the variable names that appeared immediately before
// and after the erroneously generated `let` variable name still exist
// to show the test generated enough symbols.
assert(result.code.indexOf("var ket=") >= 0);
assert(result.code.indexOf("var met=") >= 0);
});
});