Skip to content

Commit

Permalink
fix corner case in arguments (#4967)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed May 26, 2021
1 parent c8d10b7 commit e3798d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions test/compress/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e3798d9

Please sign in to comment.