[Pkg-javascript-commits] [uglifyjs] 64/228: properly cover all cases of for-in loop variables (#1536)
Jonas Smedegaard
dr at jones.dk
Sat Apr 15 14:25:17 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository uglifyjs.
commit 70d72ad8065421908ff9a8658539359789c4f460
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Fri Mar 3 02:39:57 2017 +0800
properly cover all cases of for-in loop variables (#1536)
---
lib/compress.js | 12 ++++++------
test/compress/reduce_vars.js | 17 ++++++++++++++++-
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index d4b10b5..f67f1d2 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -243,13 +243,13 @@ merge(Compressor.prototype, {
return true;
}
if (node instanceof AST_ForIn) {
- if (node.init instanceof AST_SymbolRef) {
- var d = node.init.definition();
- d.references.push(node.init);
- d.fixed = false;
- } else {
- node.init.walk(tw);
+ var sym = node.init;
+ if (sym instanceof AST_Var) {
+ sym = sym.definitions[0].name;
}
+ var d = sym.definition();
+ d.references.push(sym);
+ d.fixed = false;
node.object.walk(tw);
push();
node.body.walk(tw);
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 87b1fc2..557631b 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -563,7 +563,7 @@ inner_var_for: {
}
}
-inner_var_for_in: {
+inner_var_for_in_1: {
options = {
evaluate: true,
reduce_vars: true,
@@ -590,6 +590,21 @@ inner_var_for_in: {
}
}
+inner_var_for_in_2: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ }
+ input: {
+ for (var long_name in {})
+ console.log(long_name);
+ }
+ expect: {
+ for (var long_name in {})
+ console.log(long_name);
+ }
+}
+
issue_1533_1: {
options = {
collapse_vars: true,
--
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