avoid inline of function with special argument names (#2625)
This commit is contained in:
@@ -858,6 +858,7 @@ merge(Compressor.prototype, {
|
|||||||
|| compressor.option("unsafe") && global_names(this.name);
|
|| compressor.option("unsafe") && global_names(this.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var identifier_atom = makePredicate("Infinity NaN undefined");
|
||||||
function is_identifier_atom(node) {
|
function is_identifier_atom(node) {
|
||||||
return node instanceof AST_Infinity
|
return node instanceof AST_Infinity
|
||||||
|| node instanceof AST_NaN
|
|| node instanceof AST_NaN
|
||||||
@@ -4015,6 +4016,7 @@ merge(Compressor.prototype, {
|
|||||||
return arg.__unused
|
return arg.__unused
|
||||||
|| safe_to_inject
|
|| safe_to_inject
|
||||||
&& !catches[arg.name]
|
&& !catches[arg.name]
|
||||||
|
&& !identifier_atom(arg.name)
|
||||||
&& !scope.var_names()[arg.name];
|
&& !scope.var_names()[arg.name];
|
||||||
}) && scope;
|
}) && scope;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1092,10 +1092,9 @@ issue_2616: {
|
|||||||
expect: {
|
expect: {
|
||||||
var c = "FAIL";
|
var c = "FAIL";
|
||||||
(function() {
|
(function() {
|
||||||
(function() {
|
!function(NaN) {
|
||||||
NaN = [], (true << NaN) - 0/0 || (c = "PASS");
|
(true << NaN) - 0/0 || (c = "PASS");
|
||||||
var NaN;
|
}([]);
|
||||||
})();
|
|
||||||
})();
|
})();
|
||||||
console.log(c);
|
console.log(c);
|
||||||
}
|
}
|
||||||
@@ -1172,3 +1171,90 @@ issue_2620_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2620_3: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = "FAIL";
|
||||||
|
(function() {
|
||||||
|
function f(a, NaN) {
|
||||||
|
function g() {
|
||||||
|
switch (a) {
|
||||||
|
case a:
|
||||||
|
break;
|
||||||
|
case c = "PASS", NaN:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g();
|
||||||
|
}
|
||||||
|
f(0/0);
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = "FAIL";
|
||||||
|
(function() {
|
||||||
|
(function(a, NaN) {
|
||||||
|
(function() {
|
||||||
|
switch (a) {
|
||||||
|
case a:
|
||||||
|
break;
|
||||||
|
case c = "PASS", NaN:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
})(NaN);
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2620_4: {
|
||||||
|
rename = true,
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
dead_code: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
switches: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = "FAIL";
|
||||||
|
(function() {
|
||||||
|
function f(a, NaN) {
|
||||||
|
function g() {
|
||||||
|
switch (a) {
|
||||||
|
case a:
|
||||||
|
break;
|
||||||
|
case c = "PASS", NaN:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g();
|
||||||
|
}
|
||||||
|
f(0/0);
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = "FAIL";
|
||||||
|
!function() {
|
||||||
|
switch (NaN) {
|
||||||
|
case void (c = "PASS"):
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user