fix corner case in reduce_vars & unused (#4414)

fixes #4413
This commit is contained in:
Alex Lam S.L
2020-12-19 12:47:46 +08:00
committed by GitHub
parent e6dd471f8f
commit 9a5aede941
2 changed files with 20 additions and 0 deletions

View File

@@ -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

View File

@@ -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"
}