[Pkg-javascript-commits] [uglifyjs] 208/491: fix `collapse_vars` on default function argument (#2299)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:36 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 395a17ccda95362b1a7a5bd9ac0e6cda7f0946a8
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Mon Sep 4 02:32:33 2017 +0800

    fix `collapse_vars` on default function argument (#2299)
    
    Avoid collision with local variable `undefined` under certain corner cases.
    
    fixes #2298
---
 lib/compress.js                |  2 +-
 test/compress/collapse_vars.js | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index b6a984c..6e766fb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -847,7 +847,7 @@ merge(Compressor.prototype, {
                         if (sym.name in names) continue;
                         names[sym.name] = true;
                         var arg = iife.args[i];
-                        if (!arg) arg = make_node(AST_Undefined, sym);
+                        if (!arg) arg = make_node(AST_Undefined, sym).transform(compressor);
                         else {
                             var tw = new TreeWalker(function(node) {
                                 if (!arg) return true;
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 7686add..72123d4 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -2342,3 +2342,45 @@ duplicate_argname: {
     }
     expect_stdout: "PASS"
 }
+
+issue_2298: {
+    options = {
+        collapse_vars: true,
+        reduce_vars: true,
+        unused: true,
+    }
+    input: {
+        !function() {
+            function f() {
+                var a = undefined;
+                var undefined = a++;
+                try {
+                    !function g(b) {
+                        b[1] = "foo";
+                    }();
+                    console.log("FAIL");
+                } catch (e) {
+                    console.log("PASS");
+                }
+            }
+            f();
+        }();
+    }
+    expect: {
+        !function() {
+            (function() {
+                var a = undefined;
+                var undefined = a++;
+                try {
+                    !function(b) {
+                        (void 0)[1] = "foo";
+                    }();
+                    console.log("FAIL");
+                } catch (e) {
+                    console.log("PASS");
+                }
+            })();
+        }();
+    }
+    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