[Pkg-javascript-commits] [uglifyjs] 350/491: fix `inline` after single-use `reduce_vars` (#2623)

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 2273655c17b41ab276172afecd652a297c550c00
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Tue Dec 19 22:19:33 2017 +0800

    fix `inline` after single-use `reduce_vars` (#2623)
---
 lib/compress.js            |  4 ++-
 test/compress/functions.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index c51a90c..c95e4f8 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4004,7 +4004,9 @@ merge(Compressor.prototype, {
             var catches = Object.create(null);
             do {
                 scope = compressor.parent(level++);
-                if (scope instanceof AST_Catch) {
+                if (scope instanceof AST_SymbolRef) {
+                    scope = scope.fixed_value();
+                } else if (scope instanceof AST_Catch) {
                     catches[scope.argname.name] = true;
                 }
             } while (!(scope instanceof AST_Scope));
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 41dfc6a..bd65a11 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1101,3 +1101,74 @@ issue_2616: {
     }
     expect_stdout: "PASS"
 }
+
+issue_2620_1: {
+    options = {
+        inline: true,
+        reduce_vars: true,
+        sequences: true,
+        side_effects: true,
+        unused: true,
+    }
+    input: {
+        var c = "FAIL";
+        (function() {
+            function f(a) {
+                var b = function g(a) {
+                    a && a();
+                }();
+                if (a) {
+                    var d = c = "PASS";
+                }
+            }
+            f(1);
+        })();
+        console.log(c);
+    }
+    expect: {
+        var c = "FAIL";
+        (function() {
+            (function(a) {
+                if (function(a) {
+                    a && a();
+                }(), a) c = "PASS";
+            })(1);
+        })(),
+        console.log(c);
+    }
+    expect_stdout: "PASS"
+}
+
+issue_2620_2: {
+    options = {
+        conditionals: true,
+        evaluate: true,
+        inline: true,
+        passes: 2,
+        reduce_vars: true,
+        sequences: true,
+        side_effects: true,
+        unused: true,
+    }
+    input: {
+        var c = "FAIL";
+        (function() {
+            function f(a) {
+                var b = function g(a) {
+                    a && a();
+                }();
+                if (a) {
+                    var d = c = "PASS";
+                }
+            }
+            f(1);
+        })();
+        console.log(c);
+    }
+    expect: {
+        var c = "FAIL";
+        c = "PASS",
+        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