fix corner case in evaluate (#4143)

fixes #4142
This commit is contained in:
Alex Lam S.L
2020-09-22 05:11:25 +01:00
committed by GitHub
parent 12ac49b970
commit 3cca0d6249
2 changed files with 15 additions and 3 deletions

View File

@@ -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;
}
}