fix corner case in `functions` (#4824)
authorAlex Lam S.L <alexlamsl@gmail.com>
Thu, 25 Mar 2021 00:49:01 +0000 (00:49 +0000)
committerGitHub <noreply@github.com>
Thu, 25 Mar 2021 00:49:01 +0000 (08:49 +0800)
fixes #4823

lib/compress.js
test/compress/functions.js

index 423e134..f3e40f7 100644 (file)
@@ -6226,6 +6226,7 @@ merge(Compressor.prototype, {
                             && var_defs[sym.id] == 1
                             && sym.assignments == 0
                             && value instanceof AST_LambdaExpression
+                            && !is_arguments(sym)
                             && !is_arrow(value)
                             && assigned_once(value, sym.references)
                             && can_declare_defun(value)
index f0e0d50..4d4cb66 100644 (file)
@@ -5991,3 +5991,33 @@ issue_4788: {
     }
     expect_stdout: "PASS"
 }
+
+issue_4823: {
+    options = {
+        functions: true,
+        reduce_vars: true,
+        unused: true,
+    }
+    input: {
+        console.log(typeof function() {
+            {
+                function f() {}
+                var arguments = f();
+                function g() {}
+                var arguments = g;
+            }
+            return f && arguments;
+        }());
+    }
+    expect: {
+        console.log(typeof function() {
+            {
+                function f() {}
+                arguments = f();
+                var arguments = function() {};
+            }
+            return f && arguments;
+        }());
+    }
+    expect_stdout: "function"
+}