Fix compressing `![foo()];` as a statement
authorMihai Bazon <mihai.bazon@gmail.com>
Mon, 23 Mar 2015 21:27:00 +0000 (23:27 +0200)
committerMihai Bazon <mihai.bazon@gmail.com>
Mon, 23 Mar 2015 21:27:00 +0000 (23:27 +0200)
need to check whether the literal has any side effects before replacing that
with `false`.

lib/compress.js

index a9e1da3..41e4f17 100644 (file)
@@ -2480,7 +2480,7 @@ merge(Compressor.prototype, {
     });
 
     function literals_in_boolean_context(self, compressor) {
-        if (compressor.option("booleans") && compressor.in_boolean_context()) {
+        if (compressor.option("booleans") && compressor.in_boolean_context() && !self.has_side_effects(compressor)) {
             return make_node(AST_True, self);
         }
         return self;