fix cascade of evaluate optimisation (#1654)

Operator has changed, so break out from rest of the rules.

fixes #1649
This commit is contained in:
Alex Lam S.L
2017-03-24 22:09:19 +08:00
committed by GitHub
parent ac51d4c5a0
commit 32283a0def
2 changed files with 15 additions and 0 deletions

View File

@@ -3292,6 +3292,7 @@ merge(Compressor.prototype, {
left: self.left, left: self.left,
right: self.right.expression right: self.right.expression
}); });
break;
} }
// -a + b => b - a // -a + b => b - a
if (self.left instanceof AST_UnaryPrefix if (self.left instanceof AST_UnaryPrefix
@@ -3303,6 +3304,7 @@ merge(Compressor.prototype, {
left: self.right, left: self.right,
right: self.left.expression right: self.left.expression
}); });
break;
} }
case "*": case "*":
associative = compressor.option("unsafe_math"); associative = compressor.option("unsafe_math");

View File

@@ -789,3 +789,16 @@ unsafe_charAt_noop: {
); );
} }
} }
issue_1649: {
options = {
evaluate: true,
}
input: {
console.log(-1 + -1);
}
expect: {
console.log(-2);
}
expect_stdout: "-2";
}