fix corner case in `arguments` (#4535)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 10 Jan 2021 20:17:39 +0000 (20:17 +0000)
committerGitHub <noreply@github.com>
Sun, 10 Jan 2021 20:17:39 +0000 (04:17 +0800)
fixes #4534

lib/compress.js
test/compress/awaits.js

index f8cf75f..5526972 100644 (file)
@@ -10463,9 +10463,9 @@ merge(Compressor.prototype, {
                 argname = null;
             } else if (argname) {
                 var arg_def;
-                if (!(argname instanceof AST_SymbolFunarg)) {
-                    argname = null;
-                } else if (expr.scope.find_variable(argname.name) !== (arg_def = argname.definition())) {
+                if (!(argname instanceof AST_SymbolFunarg)
+                    || argname.name == "await"
+                    || expr.scope.find_variable(argname.name) !== (arg_def = argname.definition())) {
                     argname = null;
                 } else if (compressor.has_directive("use strict")
                     || fn.name
index 8caa60c..89d11bb 100644 (file)
@@ -977,3 +977,21 @@ issue_4454_2: {
     ]
     node_version: ">=8"
 }
+
+issue_4534: {
+    options = {
+        arguments: true,
+    }
+    input: {
+        (function(await) {
+            (async () => console.log(arguments[0]))();
+        })("PASS");
+    }
+    expect: {
+        (function(await) {
+            (async () => console.log(arguments[0]))();
+        })("PASS");
+    }
+    expect_stdout: "PASS"
+    node_version: ">=8"
+}