Skip to content

Commit

Permalink
fix corner case in evaluate (#3685)
Browse files Browse the repository at this point in the history
fixes #3684
  • Loading branch information
alexlamsl committed Jan 15, 2020
1 parent 91d87ae commit 41a6eb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/compress.js
Expand Up @@ -2497,9 +2497,10 @@ merge(Compressor.prototype, {
&& (!(right instanceof AST_Constant) || right.value == 0);
case "&&":
case "||":
case "*":
return left.is_negative_zero() || right.is_negative_zero();
case "*":
case "/":
return true;
case "%":
return left.is_negative_zero();
default:
Expand Down
18 changes: 18 additions & 0 deletions test/compress/numbers.js
Expand Up @@ -1215,3 +1215,21 @@ issue_3682_3: {
}
expect_stdout: "-Infinity"
}

issue_3684: {
options = {
evaluate: true,
}
input: {
console.log(1 / (-1 * (0 & console) + 0));
console.log(1 / ((0 & console) / -1 + 0));
}
expect: {
console.log(1 / (-1 * (0 & console) + 0));
console.log(1 / ((0 & console) / -1 + 0));
}
expect_stdout: [
"Infinity",
"Infinity",
]
}

0 comments on commit 41a6eb8

Please sign in to comment.