Fix compressing conditionals

Only transform foo() ? EXP(x) : EXP(y) into EXP(foo() ? x : y) if EXP has no
side effects.

Fix #710
This commit is contained in:
Mihai Bazon
2015-05-18 13:56:04 +03:00
parent 44fd6694eb
commit a5b60217ce
2 changed files with 9 additions and 2 deletions

View File

@@ -2356,6 +2356,7 @@ merge(Compressor.prototype, {
if (consequent instanceof AST_Call
&& alternative.TYPE === consequent.TYPE
&& consequent.args.length == alternative.args.length
&& !consequent.expression.has_side_effects(compressor)
&& consequent.expression.equivalent_to(alternative.expression)) {
if (consequent.args.length == 0) {
return make_node(AST_Seq, self, {