fix corner case in `pure_getters` (#4449)
authorAlex Lam S.L <alexlamsl@gmail.com>
Thu, 24 Dec 2020 19:58:23 +0000 (19:58 +0000)
committerGitHub <noreply@github.com>
Thu, 24 Dec 2020 19:58:23 +0000 (03:58 +0800)
fixes #4448

lib/compress.js
test/compress/arrows.js

index 29cd26b..2c1f87d 100644 (file)
@@ -358,6 +358,7 @@ merge(Compressor.prototype, {
 
     function is_arguments(def) {
         if (def.name != "arguments") return false;
+        if (!def.scope.uses_arguments) return false;
         var orig = def.orig;
         return orig.length == 1 && orig[0] instanceof AST_SymbolFunarg;
     }
index cc5aec5..990090b 100644 (file)
@@ -587,3 +587,32 @@ issue_4401: {
     ]
     node_version: ">=4"
 }
+
+issue_4448: {
+    options = {
+        pure_getters: "strict",
+        side_effects: true,
+    }
+    input: {
+        var A;
+        try {
+            (arguments => {
+                arguments[0];
+            })(A);
+        } catch (e) {
+            console.log("PASS");
+        }
+    }
+    expect: {
+        var A;
+        try {
+            (arguments => {
+                arguments[0];
+            })(A);
+        } catch (e) {
+            console.log("PASS");
+        }
+    }
+    expect_stdout: "PASS"
+    node_version: ">=4"
+}