[Pkg-javascript-commits] [uglifyjs] 123/190: Do not produce `let` as a variable name in mangle. Would previously occur in large generated functions with 21, 000+ variables. Fixes #986.
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:19 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.
commit a9d4a6291b2f3c2531ff4bdd59ac75edd0a06d60
Author: kzc <zaxxon2011 at gmail.com>
Date: Tue Mar 15 11:20:32 2016 -0400
Do not produce `let` as a variable name in mangle.
Would previously occur in large generated functions with 21,000+ variables.
Fixes #986.
---
lib/parse.js | 2 +-
test/mocha/let.js | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/lib/parse.js b/lib/parse.js
index f149515..f16d092 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -46,7 +46,7 @@
var KEYWORDS = 'break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with';
var KEYWORDS_ATOM = 'false null true';
-var RESERVED_WORDS = 'abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile yield'
+var RESERVED_WORDS = 'abstract boolean byte char class double enum export extends final float goto implements import int interface let long native package private protected public short static super synchronized this throws transient volatile yield'
+ " " + KEYWORDS_ATOM + " " + KEYWORDS;
var KEYWORDS_BEFORE_EXPRESSION = 'return new delete throw else case';
diff --git a/test/mocha/let.js b/test/mocha/let.js
new file mode 100644
index 0000000..c4ffe38
--- /dev/null
+++ b/test/mocha/let.js
@@ -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);
+ });
+});
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list