aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Mitchener <bruce.mitchener@gmail.com>2013-09-20 11:02:29 +0700
committerBruce Mitchener <bruce.mitchener@gmail.com>2013-09-25 09:54:06 +0700
commitafc3adaf66f05c7ef863dbb195e28f46e9ef33b9 (patch)
tree27895c29c2a69b963cc98724dcd2250d5291c59a
parent2ec8c7a23fbc1adee266a1e9bf8ac3f24daf3663 (diff)
Don't rewrite multiplication by 0 as 0.
This isn't safe when floats are involved as -1 * 0 is -0, not 0.
-rw-r--r--src/parseTools.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index ddfb9d01..8ce83adf 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1499,7 +1499,9 @@ function getFastValue(a, op, b, type) {
}
if (op in MUL_DIV) {
if (op == '*') {
- if (a == 0 || b == 0) {
+ // We can't eliminate where a or b are 0 as that would break things for creating
+ // a negative 0.
+ if ((a == 0 || b == 0) && !(type in Runtime.FLOAT_TYPES)) {
return '0';
} else if (a == 1) {
return b;