Skip to content

Commit

Permalink
fix corner case in evaluate (#5729)
Browse files Browse the repository at this point in the history
fixes #5728
  • Loading branch information
alexlamsl authored Nov 3, 2022
1 parent 8d28052 commit 2b1c321
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
3 changes: 2 additions & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions test/compress/bigint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 2b1c321

Please sign in to comment.