[Pkg-javascript-commits] [uglifyjs] 340/491: fix nested `inline` (#2602)

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 6c686ce59342c42b7fdcf54296e28c6c6517e6ab
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Sat Dec 16 02:16:35 2017 +0800

    fix nested `inline` (#2602)
    
    fixes #2601
---
 lib/compress.js            |  1 +
 test/compress/functions.js | 75 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/lib/compress.js b/lib/compress.js
index 0fac325..8c17422 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3942,6 +3942,7 @@ merge(Compressor.prototype, {
                         expressions.unshift(value || make_node(AST_Undefined, self));
                     }
                 } else {
+                    scope.var_names()[name.name] = true;
                     decls.unshift(make_node(AST_VarDef, name, {
                         name: name,
                         value: null
diff --git a/test/compress/functions.js b/test/compress/functions.js
index a36509a..8e67bc3 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -772,3 +772,78 @@ issue_2476: {
     }
     expect_stdout: "465"
 }
+
+issue_2601_1: {
+    options = {
+        inline: true,
+        reduce_vars: true,
+        sequences: true,
+        side_effects: true,
+        unused: true,
+    }
+    input: {
+        var a = "FAIL";
+        (function() {
+            function f(b) {
+                function g(b) {
+                    b && b();
+                }
+                g();
+                (function() {
+                    b && (a = "PASS");
+                })();
+            }
+            f("foo");
+        })();
+        console.log(a);
+    }
+    expect: {
+        var a = "FAIL";
+        (function() {
+            b = "foo",
+            function(b) {
+                b && b();
+            }(),
+            b && (a = "PASS");
+            var b;
+        })(),
+        console.log(a);
+    }
+    expect_stdout: "PASS"
+}
+
+issue_2601_2: {
+    rename = true
+    options = {
+        evaluate: true,
+        inline: true,
+        passes: 3,
+        reduce_vars: true,
+        sequences: true,
+        side_effects: true,
+        unused: true,
+    }
+    mangle = {}
+    input: {
+        var a = "FAIL";
+        (function() {
+            function f(b) {
+                function g(b) {
+                    b && b();
+                }
+                g();
+                (function() {
+                    b && (a = "PASS");
+                })();
+            }
+            f("foo");
+        })();
+        console.log(a);
+    }
+    expect: {
+        var a = "FAIL";
+        a = "PASS",
+        console.log(a);
+    }
+    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