diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js index 5a1df7c3..010cb39b 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -8283,7 +8283,9 @@ merge(Compressor.prototype, { if (is_empty(self.alternative)) self.alternative = null; if (!compressor.option("conditionals")) return self; - if (compressor.option("booleans")) mark_duplicate_condition(compressor, self.condition); + if (compressor.option("booleans") && !self.condition.has_side_effects(compressor)) { + mark_duplicate_condition(compressor, self.condition); + } // if condition can be statically determined, warn and drop // one of the blocks. note, statically determined implies // “has no side effects”; also it doesn't work for cases like @@ -11335,8 +11337,11 @@ merge(Compressor.prototype, { return make_sequence(self, expressions); } if (!compressor.option("conditionals")) return self; - if (compressor.option("booleans")) mark_duplicate_condition(compressor, self.condition); - var condition = fuzzy_eval(compressor, self.condition); + var condition = self.condition; + if (compressor.option("booleans") && !condition.has_side_effects(compressor)) { + mark_duplicate_condition(compressor, condition); + } + condition = fuzzy_eval(compressor, condition); if (!condition) { AST_Node.warn("Condition always false [{file}:{line},{col}]", self.start); return make_sequence(self, [ self.condition, self.alternative ]).optimize(compressor); |