fix corner case in `inline` (#5253)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 2 Jan 2022 08:10:39 +0000 (08:10 +0000)
committerGitHub <noreply@github.com>
Sun, 2 Jan 2022 08:10:39 +0000 (16:10 +0800)
fixes #5251

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

index 1df3bb7..2e38368 100644 (file)
@@ -12925,6 +12925,7 @@ Compressor.prototype.compress = function(node) {
             if (scope instanceof AST_Toplevel && fn.variables.size() > (arrow ? 0 : 1)) {
                 if (!compressor.toplevel.vars) return;
                 if (fn.functions.size() > 0 && !compressor.toplevel.funcs) return;
+                defined.set("arguments", true);
             }
             var async = is_async(fn);
             if (async && !(compressor.option("awaits") && is_async(scope))) return;
index 709fc63..cc8b707 100644 (file)
@@ -906,3 +906,24 @@ issue_4772: {
     expect_stdout: "PASS"
     node_version: ">=4"
 }
+
+issue_5251: {
+    options = {
+        inline: true,
+        toplevel: true,
+    }
+    input: {
+        (() => {
+            while (console.log(arguments))
+                var arguments = "FAIL";
+        })();
+    }
+    expect: {
+        (() => {
+            while (console.log(arguments))
+                var arguments = "FAIL";
+        })();
+    }
+    expect_stdout: true
+    node_version: ">=4"
+}