From 3cca0d624980e78db2c38ffaebdac53933be68fa Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 22 Sep 2020 05:11:25 +0100 Subject: fix corner case in `evaluate` (#4143) fixes #4142 --- lib/compress.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') 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; } } -- cgit v1.2.3