diff --git a/lib/output.js b/lib/output.js index 7e93d05e..ae0b1036 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1783,6 +1783,9 @@ function OutputStream(options) { output.print(self.strings[i]); output.print("`"); }); + DEFPRINT(AST_BigInt, function(output) { + output.print(this.value + "n"); + }); DEFPRINT(AST_Constant, function(output) { output.print("" + this.value); }); diff --git a/lib/parse.js b/lib/parse.js index 8fb7f383..8fd87115 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -391,7 +391,8 @@ function tokenizer($TEXT, filename, html5_comments, shebang) { var valid = parse_js_number(num); if (isNaN(valid)) parse_error("Invalid syntax: " + num); if (has_dot || has_e || peek() != "n") return token("num", valid); - return token("bigint", num.toLowerCase() + next()); + next(); + return token("bigint", num.toLowerCase()); } function read_escaped_char(in_string) { diff --git a/test/compress/bigint.js b/test/compress/bigint.js index aab50ca9..cf674a8a 100644 --- a/test/compress/bigint.js +++ b/test/compress/bigint.js @@ -90,3 +90,17 @@ issue_4801: { expect_stdout: "PASS" node_version: ">=10.4.0" } + +issue_5728: { + options = { + evaluate: true, + } + input: { + console.log("" + 4n + 2); + } + expect: { + console.log("42"); + } + expect_stdout: "42" + node_version: ">=10.4.0" +}