fix: backport #5775

This commit is contained in:
Mark Vayngrib 2023-10-31 14:49:47 +08:00
parent 90f2fad8ea
commit 607cf64c22
No known key found for this signature in database
GPG Key ID: AA48332BE2806A28
3 changed files with 19 additions and 1 deletions

View File

@ -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();

View File

@ -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) {

View File

@ -44,3 +44,17 @@ 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"
}