[Pkg-javascript-commits] [uglifyjs] 347/491: handle global constant collision with local variable after `inline` (#2617)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:51 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit 4b334edf491bd4c43a72e1a08ad2cf360f240515
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Tue Dec 19 03:05:30 2017 +0800

    handle global constant collision with local variable after `inline` (#2617)
    
    fixes #2616
---
 lib/compress.js            |  5 ++++-
 test/compress/functions.js | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index af1195d..c51a90c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4028,13 +4028,16 @@ merge(Compressor.prototype, {
                         expressions.unshift(value || make_node(AST_Undefined, self));
                     }
                 } else {
+                    var def = name.definition();
                     scope.var_names()[name.name] = true;
+                    scope.variables.set(name.name, def);
+                    scope.enclosed.push(def);
                     decls.unshift(make_node(AST_VarDef, name, {
                         name: name,
                         value: null
                     }));
                     var sym = make_node(AST_SymbolRef, name, name);
-                    name.definition().references.push(sym);
+                    def.references.push(sym);
                     expressions.unshift(make_node(AST_Assign, self, {
                         operator: "=",
                         left: sym,
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 23ed22d..c8b7ed6 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1049,3 +1049,37 @@ unsafe_call_2: {
     }
     expect_stdout: true
 }
+
+issue_2616: {
+    options = {
+        evaluate: true,
+        inline: true,
+        reduce_vars: true,
+        side_effects: true,
+        unused: true,
+    }
+    input: {
+        var c = "FAIL";
+        (function() {
+            function f() {
+                function g(NaN) {
+                    (true << NaN) - 0/0 || (c = "PASS");
+                }
+                g([]);
+            }
+            f();
+        })();
+        console.log(c);
+    }
+    expect: {
+        var c = "FAIL";
+        (function() {
+            (function() {
+                NaN = [], (true << NaN) - 0/0 || (c = "PASS");
+                var NaN;
+            })();
+        })();
+        console.log(c);
+    }
+    expect_stdout: "PASS"
+}

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