From: Alex Lam S.L Date: Wed, 15 Jan 2020 17:51:37 +0000 (+0800) Subject: fix corner case in `evaluate` (#3685) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=41a6eb892a89eef1a6a238e2ce5bc36b86cf4fee;p=UglifyJS.git fix corner case in `evaluate` (#3685) fixes #3684 --- diff --git a/lib/compress.js b/lib/compress.js index ffa5a644..a3baa7b1 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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: diff --git a/test/compress/numbers.js b/test/compress/numbers.js index fdfb6c2f..e6f6ce23 100644 --- a/test/compress/numbers.js +++ b/test/compress/numbers.js @@ -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", + ] +}