Skip to content

Commit

Permalink
fix corner case in evaluate (#3540)
Browse files Browse the repository at this point in the history
fixes #3539
  • Loading branch information
alexlamsl committed Oct 28, 2019
1 parent 24e8b47 commit f38e31b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -2901,6 +2901,7 @@ merge(Compressor.prototype, {
}
if (isNaN(result)) return compressor.find_parent(AST_With) ? this : result;
if (compressor.option("unsafe_math")
&& result
&& typeof result == "number"
&& (this.operator == "+" || this.operator == "-")) {
var digits = Math.max(0, decimals(left), decimals(right));
Expand Down
16 changes: 16 additions & 0 deletions test/compress/numbers.js
Expand Up @@ -765,3 +765,19 @@ issue_3536: {
}
expect_stdout: "number 99 11 121"
}

issue_3539: {
options = {
evaluate: true,
unsafe_math: true,
}
input: {
var a = -0 + -"";
console.log(0/a, 1/a, -1/a);
}
expect: {
var a = -0;
console.log(0/a, 1/a, -1/a);
}
expect_stdout: "NaN -Infinity Infinity"
}

0 comments on commit f38e31b

Please sign in to comment.