diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-19 11:59:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-19 11:59:42 +0800 |
commit | 96f8befdd7dbc3be9f5991f805ad8d60dfb3e6d6 (patch) | |
tree | e0e9f00e92a5aac39b088287f791c1476287c95e /lib | |
parent | cd58635dcc8f74aafa842c2015b294ff4097ba08 (diff) | |
download | tracifyjs-96f8befdd7dbc3be9f5991f805ad8d60dfb3e6d6.tar.gz tracifyjs-96f8befdd7dbc3be9f5991f805ad8d60dfb3e6d6.zip |
fix commit 88fb83a (#1622)
The following is wrong:
`a == (b ? a : c)` => `b`
Because:
- `b` may not be boolean
- `a` might have side effects
- `a == a` is not always `true` (think `NaN`)
- `a == c` is not always `false`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/lib/compress.js b/lib/compress.js index 53412a3f..41612ad7 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3057,32 +3057,6 @@ merge(Compressor.prototype, { reverse(); } } - if (/^[!=]==?$/.test(self.operator)) { - if (self.left instanceof AST_SymbolRef && self.right instanceof AST_Conditional) { - if (self.right.consequent instanceof AST_SymbolRef - && self.right.consequent.definition() === self.left.definition()) { - if (/^==/.test(self.operator)) return self.right.condition; - if (/^!=/.test(self.operator)) return self.right.condition.negate(compressor); - } - if (self.right.alternative instanceof AST_SymbolRef - && self.right.alternative.definition() === self.left.definition()) { - if (/^==/.test(self.operator)) return self.right.condition.negate(compressor); - if (/^!=/.test(self.operator)) return self.right.condition; - } - } - if (self.right instanceof AST_SymbolRef && self.left instanceof AST_Conditional) { - if (self.left.consequent instanceof AST_SymbolRef - && self.left.consequent.definition() === self.right.definition()) { - if (/^==/.test(self.operator)) return self.left.condition; - if (/^!=/.test(self.operator)) return self.left.condition.negate(compressor); - } - if (self.left.alternative instanceof AST_SymbolRef - && self.left.alternative.definition() === self.right.definition()) { - if (/^==/.test(self.operator)) return self.left.condition.negate(compressor); - if (/^!=/.test(self.operator)) return self.left.condition; - } - } - } } self = self.lift_sequences(compressor); if (compressor.option("comparisons")) switch (self.operator) { |