mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
Closes #3347. Implementation follows the approach described by @overlookmotel [here](https://github.com/oxc-project/oxc/issues/3347#issuecomment-2119004288).
14 lines
640 B
TypeScript
14 lines
640 B
TypeScript
// Tests large numbers that may overflow integer parsing, but are all small
|
|
// enough to be valid f64s. Related to PR #4072 and issue #3347.
|
|
|
|
let HEX_INT_LARGER_THAN_MAX_SAFE_INTEGER: number = 0x10000000000000000
|
|
let OCT_INT_LARGER_THAN_MAX_SAFE_INTEGER: number = 0o40000000000000000
|
|
let BIN_INT_LARGER_THAN_MAX_SAFE_INTEGER: number = 0b00010000000000000000000000000000000000000000000000000000000000000000;
|
|
|
|
if (
|
|
HEX_INT_LARGER_THAN_MAX_SAFE_INTEGER === 0 ||
|
|
OCT_INT_LARGER_THAN_MAX_SAFE_INTEGER === 0 ||
|
|
BIN_INT_LARGER_THAN_MAX_SAFE_INTEGER === 0
|
|
) {
|
|
throw new Error('Large numeric literals are overflowing when parsed')
|
|
}
|