diff options
author | Mihai Bazon <mihai.bazon@gmail.com> | 2016-09-01 16:32:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 16:32:22 +0300 |
commit | 7d8dea3b2675f9d86ea15bb031b7fe166858d67e (patch) | |
tree | 9dc3e31bf38451f187b19b67745c36773274697d /lib | |
parent | 0bd8053524760531eb582ef0716fcfe2104c3014 (diff) | |
parent | 25fc02743af0e3fec6b10ffdb5cee3b7f22b9889 (diff) | |
download | tracifyjs-7d8dea3b2675f9d86ea15bb031b7fe166858d67e.tar.gz tracifyjs-7d8dea3b2675f9d86ea15bb031b7fe166858d67e.zip |
Merge pull request #1277 from kzc/fix-string-plus-opt
Account for side effects in `string + expr` optimization
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index 8f786d73..8a08572f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2499,8 +2499,8 @@ merge(Compressor.prototype, { case "+": var ll = self.left.evaluate(compressor); var rr = self.right.evaluate(compressor); - if ((ll.length > 1 && ll[0] instanceof AST_String && ll[1]) || - (rr.length > 1 && rr[0] instanceof AST_String && rr[1])) { + if ((ll.length > 1 && ll[0] instanceof AST_String && ll[1] && !self.right.has_side_effects(compressor)) || + (rr.length > 1 && rr[0] instanceof AST_String && rr[1] && !self.left.has_side_effects(compressor))) { compressor.warn("+ in boolean context always true [{file}:{line},{col}]", self.start); return make_node(AST_True, self); } |