aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-19 12:47:46 +0800
committerGitHub <noreply@github.com>2020-12-19 12:47:46 +0800
commit9a5aede94147bf5769054fd933b1c15690915d25 (patch)
tree4901f7aea01c91dc94a43ee6e04c7324901a5528
parente6dd471f8fff84c878153008139150a090c5ba19 (diff)
downloadtracifyjs-9a5aede94147bf5769054fd933b1c15690915d25.tar.gz
tracifyjs-9a5aede94147bf5769054fd933b1c15690915d25.zip
fix corner case in `reduce_vars` & `unused` (#4414)
fixes #4413
-rw-r--r--lib/scope.js1
-rw-r--r--test/compress/drop-unused.js19
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/scope.js b/lib/scope.js
index 187309ca..fac673bc 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -257,6 +257,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
sym = self.def_global(node);
} else if (name == "arguments"
&& sym.orig[0] instanceof AST_SymbolFunarg
+ && !(sym.orig[1] instanceof AST_SymbolFunarg)
&& !(sym.scope instanceof AST_Arrow)) {
var parent = tw.parent();
if (parent instanceof AST_Assign && parent.left === node
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 1c9ab61f..d048707a 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -3134,3 +3134,22 @@ issue_4404: {
}
expect_stdout: "PASS"
}
+
+issue_4413: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ console.log(function f(arguments) {
+ var arguments = function() {};
+ return arguments.length;
+ }());
+ }
+ expect: {
+ console.log(function(arguments) {
+ return function() {}.length;
+ }());
+ }
+ expect_stdout: "0"
+}