enhance arguments (#4296)
This commit is contained in:
@@ -9572,13 +9572,14 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var parent = compressor.parent();
|
var parent = compressor.parent();
|
||||||
|
var assigned = is_lhs(compressor.self(), parent);
|
||||||
var def, fn, fn_parent;
|
var def, fn, fn_parent;
|
||||||
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())
|
||||||
&& prop instanceof AST_Number
|
&& prop instanceof AST_Number
|
||||||
&& (fn = expr.scope.resolve()) === find_lambda()
|
&& (fn = expr.scope.resolve()) === find_lambda()
|
||||||
&& fn.uses_arguments !== "d") {
|
&& !(assigned && fn.uses_arguments === "d")) {
|
||||||
var index = prop.value;
|
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 = [];
|
||||||
@@ -9616,7 +9617,7 @@ merge(Compressor.prototype, {
|
|||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_lhs(compressor.self(), parent)) return self;
|
if (assigned) return self;
|
||||||
if (compressor.option("sequences")
|
if (compressor.option("sequences")
|
||||||
&& parent.TYPE != "Call"
|
&& parent.TYPE != "Call"
|
||||||
&& !(parent instanceof AST_ForIn && parent.init === self)) {
|
&& !(parent instanceof AST_ForIn && parent.init === self)) {
|
||||||
|
|||||||
@@ -808,7 +808,7 @@ issue_4200: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4291: {
|
issue_4291_1: {
|
||||||
options = {
|
options = {
|
||||||
arguments: true,
|
arguments: true,
|
||||||
keep_fargs: "strict",
|
keep_fargs: "strict",
|
||||||
@@ -827,3 +827,27 @@ issue_4291: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4291_2: {
|
||||||
|
options = {
|
||||||
|
arguments: true,
|
||||||
|
keep_fargs: "strict",
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = function() {
|
||||||
|
if (arguments[0])
|
||||||
|
arguments[1] = "PASS";
|
||||||
|
return arguments;
|
||||||
|
}(42);
|
||||||
|
console.log(a[1], a[0], a.length);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = function(argument_0) {
|
||||||
|
if (argument_0)
|
||||||
|
arguments[1] = "PASS";
|
||||||
|
return arguments;
|
||||||
|
}(42);
|
||||||
|
console.log(a[1], a[0], a.length);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS 42 1"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user