fix cascade on delete operator (#1687)
Conditions including strict mode would make `delete` return `true` or `false`, and are too complex to be evaluated by the compressor. Suppress assignment folding into said operator. fixes #1685
This commit is contained in:
@@ -2542,7 +2542,6 @@ merge(Compressor.prototype, {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var case_side_effects = branch instanceof AST_Case && branch.expression.has_side_effects(compressor);
|
|
||||||
if (aborts(branch)) {
|
if (aborts(branch)) {
|
||||||
var block = make_node(AST_BlockStatement, branch, branch).print_to_string();
|
var block = make_node(AST_BlockStatement, branch, branch).print_to_string();
|
||||||
if (!fallthrough && prev_block === block) body[body.length - 1].body = [];
|
if (!fallthrough && prev_block === block) body[body.length - 1].body = [];
|
||||||
@@ -2946,7 +2945,10 @@ merge(Compressor.prototype, {
|
|||||||
field = "left";
|
field = "left";
|
||||||
}
|
}
|
||||||
} else if (cdr instanceof AST_Call
|
} else if (cdr instanceof AST_Call
|
||||||
|| cdr instanceof AST_Unary && cdr.operator != "++" && cdr.operator != "--") {
|
|| cdr instanceof AST_Unary
|
||||||
|
&& cdr.operator != "delete"
|
||||||
|
&& cdr.operator != "++"
|
||||||
|
&& cdr.operator != "--") {
|
||||||
field = "expression";
|
field = "expression";
|
||||||
} else break;
|
} else break;
|
||||||
parent = cdr;
|
parent = cdr;
|
||||||
|
|||||||
@@ -306,3 +306,27 @@ unsafe_undefined: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_1685: {
|
||||||
|
options = {
|
||||||
|
cascade: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 100, b = 10;
|
||||||
|
function f() {
|
||||||
|
var a = (a--, delete a && --b);
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 100, b = 10;
|
||||||
|
function f() {
|
||||||
|
var a = (a--, delete a && --b);
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user