fix corner case in arguments (#4967)

This commit is contained in:
Alex Lam S.L
2021-05-26 15:24:26 +01:00
committed by GitHub
parent c8d10b7cde
commit e3798d9a76
2 changed files with 21 additions and 2 deletions

View File

@@ -11543,15 +11543,15 @@ merge(Compressor.prototype, {
}
var parent = compressor.parent();
var assigned = is_lhs(compressor.self(), parent);
var def, fn, fn_parent;
var def, fn, fn_parent, index;
if (compressor.option("arguments")
&& expr instanceof AST_SymbolRef
&& is_arguments(def = expr.definition())
&& !expr.in_arg
&& prop instanceof AST_Number
&& Math.floor(index = prop.value) == index
&& (fn = def.scope) === find_lambda()
&& fn.uses_arguments < (assigned ? 2 : 3)) {
var index = prop.value;
if (parent instanceof AST_UnaryPrefix && parent.operator == "delete") {
if (!def.deleted) def.deleted = [];
def.deleted[index] = true;

View File

@@ -254,6 +254,25 @@ duplicate_argname: {
expect_stdout: "bar 42 foo 42 bar"
}
fraction: {
options = {
arguments: true,
keep_fargs: false,
reduce_vars: true,
}
input: {
console.log(function() {
return arguments[0.3];
}("FAIL") || "PASS");
}
expect: {
console.log(function() {
return arguments[0.3];
}("FAIL") || "PASS");
}
expect_stdout: "PASS"
}
issue_3273: {
options = {
arguments: true,