fix corner case in arguments (#4967)
This commit is contained in:
@@ -11543,15 +11543,15 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
var parent = compressor.parent();
|
var parent = compressor.parent();
|
||||||
var assigned = is_lhs(compressor.self(), parent);
|
var assigned = is_lhs(compressor.self(), parent);
|
||||||
var def, fn, fn_parent;
|
var def, fn, fn_parent, index;
|
||||||
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
|
&& !expr.in_arg
|
||||||
&& prop instanceof AST_Number
|
&& prop instanceof AST_Number
|
||||||
|
&& Math.floor(index = prop.value) == index
|
||||||
&& (fn = def.scope) === find_lambda()
|
&& (fn = def.scope) === find_lambda()
|
||||||
&& fn.uses_arguments < (assigned ? 2 : 3)) {
|
&& fn.uses_arguments < (assigned ? 2 : 3)) {
|
||||||
var index = prop.value;
|
|
||||||
if (parent instanceof AST_UnaryPrefix && parent.operator == "delete") {
|
if (parent instanceof AST_UnaryPrefix && parent.operator == "delete") {
|
||||||
if (!def.deleted) def.deleted = [];
|
if (!def.deleted) def.deleted = [];
|
||||||
def.deleted[index] = true;
|
def.deleted[index] = true;
|
||||||
|
|||||||
@@ -254,6 +254,25 @@ duplicate_argname: {
|
|||||||
expect_stdout: "bar 42 foo 42 bar"
|
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: {
|
issue_3273: {
|
||||||
options = {
|
options = {
|
||||||
arguments: true,
|
arguments: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user