fix assignment substitution in sequences (#1643)

take side effects of binary boolean operations into account

fixes #1639
This commit is contained in:
Alex Lam S.L
2017-03-24 14:30:31 +08:00
committed by GitHub
parent 2e0dc97003
commit f3a1694a41
2 changed files with 94 additions and 1 deletions

View File

@@ -2934,7 +2934,12 @@ merge(Compressor.prototype, {
return car;
}
if (cdr instanceof AST_Binary && !(cdr instanceof AST_Assign)) {
field = cdr.left.is_constant() ? "right" : "left";
if (cdr.left.is_constant()) {
if (cdr.operator == "||" || cdr.operator == "&&") break;
field = "right";
} else {
field = "left";
}
} else if (cdr instanceof AST_Call
|| cdr instanceof AST_Unary && cdr.operator != "++" && cdr.operator != "--") {
field = "expression";