fix corner case in `arguments` (#4201)
authorAlex Lam S.L <alexlamsl@gmail.com>
Mon, 12 Oct 2020 11:03:21 +0000 (12:03 +0100)
committerGitHub <noreply@github.com>
Mon, 12 Oct 2020 11:03:21 +0000 (19:03 +0800)
fixes #4200

lib/compress.js
test/compress/arguments.js

index f930dd8..3464a23 100644 (file)
@@ -9180,6 +9180,7 @@ merge(Compressor.prototype, {
             var i = 0, p;
             while (p = compressor.parent(i++)) {
                 if (p instanceof AST_Lambda) {
+                    if (p instanceof AST_Accessor) return;
                     fn_parent = compressor.parent(i);
                     return p;
                 }
index dc00eef..a835aef 100644 (file)
@@ -783,3 +783,27 @@ issue_3420_7: {
     }
     expect_stdout: "true"
 }
+
+issue_4200: {
+    options = {
+        arguments: true,
+        keep_fargs: false,
+    }
+    input: {
+        var o = {
+            get p() {
+                return arguments[0];
+            },
+        };
+        console.log(o.p);
+    }
+    expect: {
+        var o = {
+            get p() {
+                return arguments[0];
+            },
+        };
+        console.log(o.p);
+    }
+    expect_stdout: "undefined"
+}