aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-22 05:11:25 +0100
committerGitHub <noreply@github.com>2020-09-22 12:11:25 +0800
commit3cca0d624980e78db2c38ffaebdac53933be68fa (patch)
treeddc6b61a2a31e9e356dddb4fb07de899a071a97d /lib
parent12ac49b970f272f76f76fcfa954306ab821b9ac9 (diff)
downloadtracifyjs-3cca0d624980e78db2c38ffaebdac53933be68fa.tar.gz
tracifyjs-3cca0d624980e78db2c38ffaebdac53933be68fa.zip
fix corner case in `evaluate` (#4143)
fixes #4142
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index cf46e47f..f66b7185 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -7767,12 +7767,11 @@ merge(Compressor.prototype, {
associative = compressor.option("unsafe_math");
// +a - b => a - b
// a - +b => a - b
- [ "left", "right" ].forEach(function(operand) {
+ if (self.operator != "+") [ "left", "right" ].forEach(function(operand) {
var node = self[operand];
if (node instanceof AST_UnaryPrefix && node.operator == "+") {
var exp = node.expression;
- if (exp.is_boolean(compressor) || exp.is_number(compressor)
- || self.operator != "+" && exp.is_string(compressor)) {
+ if (exp.is_boolean(compressor) || exp.is_number(compressor) || exp.is_string(compressor)) {
self[operand] = exp;
}
}