aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai.bazon@gmail.com>2015-05-18 13:56:04 +0300
committerMihai Bazon <mihai.bazon@gmail.com>2015-05-18 13:56:04 +0300
commita5b60217cede3f214153e62087d32274aa0859e5 (patch)
tree501fa6ea3fe8487df182c62e4d1372a4d07fccee /lib/compress.js
parent44fd6694ebf1def9974915b163cfc79114eb8e80 (diff)
downloadtracifyjs-a5b60217cede3f214153e62087d32274aa0859e5.tar.gz
tracifyjs-a5b60217cede3f214153e62087d32274aa0859e5.zip
Fix compressing conditionals
Only transform foo() ? EXP(x) : EXP(y) into EXP(foo() ? x : y) if EXP has no side effects. Fix #710
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 944db1d2..530e7c2f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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, {