fix corner case in reduce_vars & unused

fixes #4413
This commit is contained in:
alexlamsl 2020-12-19 11:40:37 +08:00
parent 0f55bd92f1
commit c80f9468cb
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); sym = self.def_global(node);
} else if (name == "arguments" } else if (name == "arguments"
&& sym.orig[0] instanceof AST_SymbolFunarg && sym.orig[0] instanceof AST_SymbolFunarg
&& !(sym.orig[1] instanceof AST_SymbolFunarg)
&& !(sym.scope instanceof AST_Arrow)) { && !(sym.scope instanceof AST_Arrow)) {
var parent = tw.parent(); var parent = tw.parent();
if (parent instanceof AST_Assign && parent.left === node if (parent instanceof AST_Assign && parent.left === node

View File

@ -3134,3 +3134,22 @@ issue_4404: {
} }
expect_stdout: "PASS" 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"
}