fix corner case in `inline` (#5257)
authorAlex Lam S.L <alexlamsl@gmail.com>
Mon, 3 Jan 2022 02:13:29 +0000 (02:13 +0000)
committerGitHub <noreply@github.com>
Mon, 3 Jan 2022 02:13:29 +0000 (10:13 +0800)
fixes #5256

lib/compress.js
test/compress/default-values.js

index 5997a4b..d5dc723 100644 (file)
@@ -12937,9 +12937,7 @@ Compressor.prototype.compress = function(node) {
             if (!fn.variables.all(function(def, name) {
                 if (in_loop) in_loop.push(def);
                 if (!defined.has(name) && !names.has(name)) return true;
-                if (name != "arguments") return false;
-                if (scope.uses_arguments) return false;
-                return def.references.length == def.replaced;
+                return !arrow && name == "arguments" && def.orig.length == 1;
             })) return;
             if (in_loop && in_loop.length > 0 && is_reachable(fn, in_loop)) return;
             var simple_argnames = true;
index 3ad55f0..4d1d60b 100644 (file)
@@ -2092,3 +2092,24 @@ issue_5246_3: {
     expect_stdout: "undefined"
     node_version: ">=6"
 }
+
+issue_5256: {
+    options = {
+        inline: true,
+    }
+    input: {
+        (function(arguments = console.log) {
+            console;
+        })();
+        console.log(typeof arguments);
+    }
+    expect: {
+        // Syntax error on Node.js v6
+        (function(arguments = console.log) {
+            console;
+        })();
+        console.log(typeof arguments);
+    }
+    expect_stdout: "undefined"
+    node_version: ">=8"
+}