fix corner case in `inline` (#3859)
authorAlex Lam S.L <alexlamsl@gmail.com>
Fri, 8 May 2020 07:03:29 +0000 (08:03 +0100)
committerGitHub <noreply@github.com>
Fri, 8 May 2020 07:03:29 +0000 (15:03 +0800)
fixes #3858

lib/compress.js
test/compress/pure_funcs.js

index 4dae2a9..09eaacb 100644 (file)
@@ -4030,6 +4030,7 @@ merge(Compressor.prototype, {
             if (stat instanceof AST_Return) {
                 var call = stat.value;
                 if (!call || call.TYPE != "Call") break;
+                if (call.is_expr_pure(compressor)) break;
                 var fn = call.expression;
                 if (fn instanceof AST_SymbolRef) {
                     if (self.name && self.name.definition() === fn.definition()) break;
index 48140dd..2ca21d0 100644 (file)
@@ -680,3 +680,29 @@ issue_3325_2: {
     }
     expect_stdout: "PASS"
 }
+
+issue_3858: {
+    options = {
+        collapse_vars: true,
+        inline: true,
+        keep_fargs: "strict",
+        unused: true,
+    }
+    input: {
+        var f = function(a) {
+            return /*@__PURE__*/ function(b) {
+                console.log(b);
+            }(a);
+        };
+        f("PASS");
+    }
+    expect: {
+        var f = function(a) {
+            return function() {
+                console.log(a);
+            }();
+        };
+        f("PASS");
+    }
+    expect_stdout: "PASS"
+}