fix reduce_vars on boolean binary expressions
Side effects of `&&` and `||` have not mattered until #1814, which takes assignment expressions into account.
This commit is contained in:
parent
71a8d0d236
commit
afa131b3e3
|
|
@ -340,6 +340,14 @@ merge(Compressor.prototype, {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (node instanceof AST_Binary
|
||||||
|
&& (node.operator == "&&" || node.operator == "||")) {
|
||||||
|
node.left.walk(tw);
|
||||||
|
push();
|
||||||
|
node.right.walk(tw);
|
||||||
|
pop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (node instanceof AST_If) {
|
if (node instanceof AST_If) {
|
||||||
node.condition.walk(tw);
|
node.condition.walk(tw);
|
||||||
push();
|
push();
|
||||||
|
|
|
||||||
|
|
@ -2218,3 +2218,26 @@ try_abort: {
|
||||||
}
|
}
|
||||||
expect_stdout: "1 undefined"
|
expect_stdout: "1 undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean_binary_assign: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
!function() {
|
||||||
|
var a;
|
||||||
|
void 0 && (a = 1);
|
||||||
|
console.log(a);
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
!function() {
|
||||||
|
var a;
|
||||||
|
void 0;
|
||||||
|
console.log(a);
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user