[Pkg-javascript-commits] [uglifyjs] 63/228: fix reference marking in for-in loops (#1535)

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 fe9227a41bd13a8e58be1e17636a96d09e0fd956
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Mar 3 00:56:06 2017 +0800

    fix reference marking in for-in loops (#1535)
    
    fixes #1533
---
 lib/compress.js              |  6 +++++-
 test/compress/reduce_vars.js | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index 01fdeea..d4b10b5 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -244,7 +244,11 @@ merge(Compressor.prototype, {
                 }
                 if (node instanceof AST_ForIn) {
                     if (node.init instanceof AST_SymbolRef) {
-                        node.init.definition().fixed = false;
+                        var d = node.init.definition();
+                        d.references.push(node.init);
+                        d.fixed = false;
+                    } else {
+                        node.init.walk(tw);
                     }
                     node.object.walk(tw);
                     push();
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index e38c317..87b1fc2 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -589,3 +589,39 @@ inner_var_for_in: {
         x(1, b, c, d);
     }
 }
+
+issue_1533_1: {
+    options = {
+        collapse_vars: true,
+        reduce_vars: true,
+    }
+    input: {
+        var id = "";
+        for (id in {break: "me"})
+            console.log(id);
+    }
+    expect: {
+        var id = "";
+        for (id in {break: "me"})
+            console.log(id);
+    }
+}
+
+issue_1533_2: {
+    options = {
+        evaluate: true,
+        reduce_vars: true,
+    }
+    input: {
+        var id = "";
+        for (var id in {break: "me"})
+            console.log(id);
+        console.log(id);
+    }
+    expect: {
+        var id = "";
+        for (var id in {break: "me"})
+            console.log(id);
+        console.log(id);
+    }
+}

-- 
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