aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js5
-rw-r--r--test/compress/numbers.js13
2 files changed, 15 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;
}
}
diff --git a/test/compress/numbers.js b/test/compress/numbers.js
index 7f355a12..c7aab685 100644
--- a/test/compress/numbers.js
+++ b/test/compress/numbers.js
@@ -1322,3 +1322,16 @@ issue_4137: {
}
expect_stdout: "0"
}
+
+issue_4142: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ console.log("" + +(0 === console));
+ }
+ expect: {
+ console.log("" + +(0 === console));
+ }
+ expect_stdout: "0"
+}