fix corner case in arguments

fixes #4399
This commit is contained in:
alexlamsl 2020-12-18 08:14:55 +08:00
parent c1256c399a
commit d2584c6b86
3 changed files with 24 additions and 1 deletions

View File

@ -1314,7 +1314,7 @@ var AST_Label = DEFNODE("Label", "references", {
} }
}, AST_Symbol); }, AST_Symbol);
var AST_SymbolRef = DEFNODE("SymbolRef", "fixed", { var AST_SymbolRef = DEFNODE("SymbolRef", "fixed in_arg", {
$documentation: "Reference to some symbol (not definition/declaration)", $documentation: "Reference to some symbol (not definition/declaration)",
}, AST_Symbol); }, AST_Symbol);

View File

@ -9883,6 +9883,7 @@ merge(Compressor.prototype, {
if (compressor.option("arguments") if (compressor.option("arguments")
&& expr instanceof AST_SymbolRef && expr instanceof AST_SymbolRef
&& is_arguments(def = expr.definition()) && is_arguments(def = expr.definition())
&& !expr.in_arg
&& prop instanceof AST_Number && prop instanceof AST_Number
&& (fn = def.scope) === find_lambda() && (fn = def.scope) === find_lambda()
&& !(assigned && fn.uses_arguments === "d")) { && !(assigned && fn.uses_arguments === "d")) {

View File

@ -1906,3 +1906,25 @@ issue_4395: {
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6"
} }
issue_4399: {
options = {
arguments: true,
}
input: {
console.log(function({
[arguments[1]]: a,
}, b) {
return a;
}([ "PASS" ], 0));
}
expect: {
console.log(function({
[arguments[1]]: a,
}, b) {
return a;
}([ "PASS" ], 0));
}
expect_stdout: "PASS"
node_version: ">=6"
}