suppress `inline` within substituted `AST_Scope` (#2658)
authorAlex Lam S.L <alexlamsl@gmail.com>
Tue, 26 Dec 2017 10:56:59 +0000 (18:56 +0800)
committerGitHub <noreply@github.com>
Tue, 26 Dec 2017 10:56:59 +0000 (18:56 +0800)
fixes #2657

lib/compress.js
test/compress/functions.js

index 8df6bbd..bb35542 100644 (file)
@@ -3982,7 +3982,7 @@ merge(Compressor.prototype, {
             do {
                 scope = compressor.parent(++level);
                 if (scope instanceof AST_SymbolRef) {
-                    scope = scope.fixed_value();
+                    if (scope.fixed_value() instanceof AST_Scope) return false;
                 } else if (scope instanceof AST_Catch) {
                     catches[scope.argname.name] = true;
                 }
index 02b4ab3..7f35de7 100644 (file)
@@ -1447,3 +1447,33 @@ recursive_inline: {
     }
     expect: {}
 }
+
+issue_2657: {
+    options = {
+        inline: true,
+        reduce_vars: true,
+        sequences: true,
+        unused: true,
+    }
+    input: {
+        "use strict";
+        console.log(function f() {
+            return h;
+            function g(b) {
+                return b || b();
+            }
+            function h(a) {
+                g(a);
+                return a;
+            }
+        }()(42));
+    }
+    expect: {
+        "use strict";
+        console.log(function(a) {
+            return b = a, b || b(), a;
+            var b;
+        }(42));
+    }
+    expect_stdout: "42"
+}