Skip to content

Commit 2b1c321

Browse files
authored
fix corner case in evaluate (#5729)
fixes #5728
1 parent 8d28052 commit 2b1c321

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/output.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,9 @@ function OutputStream(options) {
17831783
output.print(self.strings[i]);
17841784
output.print("`");
17851785
});
1786+
DEFPRINT(AST_BigInt, function(output) {
1787+
output.print(this.value + "n");
1788+
});
17861789
DEFPRINT(AST_Constant, function(output) {
17871790
output.print("" + this.value);
17881791
});

lib/parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
391391
var valid = parse_js_number(num);
392392
if (isNaN(valid)) parse_error("Invalid syntax: " + num);
393393
if (has_dot || has_e || peek() != "n") return token("num", valid);
394-
return token("bigint", num.toLowerCase() + next());
394+
next();
395+
return token("bigint", num.toLowerCase());
395396
}
396397

397398
function read_escaped_char(in_string) {

test/compress/bigint.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,17 @@ issue_4801: {
9090
expect_stdout: "PASS"
9191
node_version: ">=10.4.0"
9292
}
93+
94+
issue_5728: {
95+
options = {
96+
evaluate: true,
97+
}
98+
input: {
99+
console.log("" + 4n + 2);
100+
}
101+
expect: {
102+
console.log("42");
103+
}
104+
expect_stdout: "42"
105+
node_version: ">=10.4.0"
106+
}

0 commit comments

Comments
 (0)