fix corner case in `arguments` (#4387)
authorAlex Lam S.L <alexlamsl@gmail.com>
Thu, 17 Dec 2020 05:51:34 +0000 (05:51 +0000)
committerGitHub <noreply@github.com>
Thu, 17 Dec 2020 05:51:34 +0000 (13:51 +0800)
fixes #4386

lib/compress.js
test/compress/destructured.js

index b767264..a46cd42 100644 (file)
@@ -9843,6 +9843,8 @@ merge(Compressor.prototype, {
             var argname = fn.argnames[index];
             if (def.deleted && def.deleted[index]) {
                 argname = null;
+            } else if (argname instanceof AST_Destructured) {
+                argname = null;
             } else if (argname && (compressor.has_directive("use strict")
                 || !(fn_parent instanceof AST_Call && index < fn_parent.args.length))) {
                 var arg_def = argname.definition();
index 9fd425d..81beb7f 100644 (file)
@@ -1866,3 +1866,23 @@ issue_4383: {
     expect_stdout: "1"
     node_version: ">=6"
 }
+
+issue_4386: {
+    options = {
+        arguments: true,
+    }
+    input: {
+        function f({}) {
+            return arguments[0];
+        }
+        console.log(f("PASS"));
+    }
+    expect: {
+        function f({}) {
+            return arguments[0];
+        }
+        console.log(f("PASS"));
+    }
+    expect_stdout: "PASS"
+    node_version: ">=6"
+}