From e062dc8ddf661d560d8778a0e408cb5e78360fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Santos?= Date: Fri, 17 Feb 2023 13:05:38 +0000 Subject: [PATCH] Do not mark BigInt `is_number`. Closes #1315 --- lib/compress/inference.js | 3 ++- test/compress/comparing.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/compress/inference.js b/lib/compress/inference.js index 91067b7d6..29434a66b 100644 --- a/lib/compress/inference.js +++ b/lib/compress/inference.js @@ -45,6 +45,7 @@ import { AST_Array, AST_Arrow, AST_Assign, + AST_BigInt, AST_Binary, AST_Block, AST_BlockStatement, @@ -171,7 +172,7 @@ export const unary_side_effects = makePredicate("delete ++ --"); def_is_number(AST_Number, return_true); const unary = makePredicate("+ - ~ ++ --"); def_is_number(AST_Unary, function() { - return unary.has(this.operator); + return unary.has(this.operator) && !(this.expression instanceof AST_BigInt); }); const numeric_ops = makePredicate("- * / % & | ^ << >> >>>"); def_is_number(AST_Binary, function(compressor) { diff --git a/test/compress/comparing.js b/test/compress/comparing.js index d56445e0e..dfc3d813f 100644 --- a/test/compress/comparing.js +++ b/test/compress/comparing.js @@ -315,3 +315,16 @@ issue_2857_6: { } expect_stdout: "true" } + +bigint_vs_number: { + options = { + comparisons: true, + } + input: { + if (-1 !== -1n) console.log("PASS"); + } + expect: { + if (-1 !== -1n) console.log("PASS"); + } + expect_stdout: "PASS" +}