fix corner case in `side_effects` (#4622)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 7 Feb 2021 14:40:41 +0000 (14:40 +0000)
committerGitHub <noreply@github.com>
Sun, 7 Feb 2021 14:40:41 +0000 (22:40 +0800)
fixes #4621

lib/compress.js
test/compress/rests.js

index 7a6a0bc..afb555f 100644 (file)
@@ -8295,7 +8295,7 @@ merge(Compressor.prototype, {
                 if (has_arg_refs(argname)) return false;
             }
             return true;
-        });
+        }) && !(fn.rest instanceof AST_Destructured && has_arg_refs(fn.rest));
         var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor);
         if (can_inline && stat instanceof AST_Return) {
             var value = stat.value;
index 42e6295..21adf20 100644 (file)
@@ -696,3 +696,21 @@ issue_4575: {
     expect_stdout: "PASS 0"
     node_version: ">=6"
 }
+
+issue_4621: {
+    options = {
+        side_effects: true,
+    }
+    input: {
+        (function f(a, ...{
+            [console.log(a)]: b,
+        }) {})("PASS");
+    }
+    expect: {
+        (function f(a, ...{
+            [console.log(a)]: b,
+        }) {})("PASS");
+    }
+    expect_stdout: "PASS"
+    node_version: ">=6"
+}