Skip to content

Commit

Permalink
Do not mark BigInt is_number. Closes #1315
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiosantoscode committed Feb 17, 2023
1 parent e0acb3c commit e062dc8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/compress/inference.js
Expand Up @@ -45,6 +45,7 @@ import {
AST_Array,
AST_Arrow,
AST_Assign,
AST_BigInt,
AST_Binary,
AST_Block,
AST_BlockStatement,
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions test/compress/comparing.js
Expand Up @@ -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"
}

0 comments on commit e062dc8

Please sign in to comment.