diff --git a/lib/output.js b/lib/output.js index c0bc58eb..3f3d2cd5 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1358,6 +1358,9 @@ function OutputStream(options) { DEFPRINT(AST_Const, function(self, output){ self._do_print(output, "const"); }); + DEFPRINT(AST_BigInt, function(output) { + output.print(this.value + "n"); + }); DEFPRINT(AST_Import, function(self, output) { output.print("import"); output.space(); diff --git a/lib/parse.js b/lib/parse.js index f937abc0..4355432b 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -412,7 +412,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 0d3d132b..28bfaac5 100644 --- a/test/compress/bigint.js +++ b/test/compress/bigint.js @@ -43,4 +43,18 @@ Number: { } expect_stdout: "-1148098955808013200" node_version: ">=10" +} + +issue_5728: { + options = { + evaluate: true, + } + input: { + console.log("" + 4n + 2); + } + expect: { + console.log("42"); + } + expect_stdout: "42" + node_version: ">=10.4.0" } \ No newline at end of file