LibJS: Handle out-of-range prefixed numbers in Token::double_value
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This regressed in cd15b1a2c9.

If a prefixed number is out-of-range of a u64, stroul would previously
fall back to ULONG_MAX. This patch restores that behavior.
This commit is contained in:
Timothy Flynn 2025-08-10 06:41:15 -04:00 committed by Andreas Kling
commit e2b245add1
Notes: github-actions[bot] 2025-08-10 11:36:34 +00:00
2 changed files with 20 additions and 4 deletions

View file

@ -50,3 +50,18 @@ test("invalid numeric literals", () => {
expect("1in[]").not.toEval();
expect("2instanceof foo").not.toEval();
});
test("out-of-range literals", () => {
expect(0x10000000000000000).toBe(18446744073709552000);
expect(-0x10000000000000000).toBe(-18446744073709552000);
expect(0o2000000000000000000000).toBe(18446744073709552000);
expect(-0o2000000000000000000000).toBe(-18446744073709552000);
expect(0b10000000000000000000000000000000000000000000000000000000000000000).toBe(
18446744073709552000
);
expect(-0b10000000000000000000000000000000000000000000000000000000000000000).toBe(
-18446744073709552000
);
});