-
Notifications
You must be signed in to change notification settings - Fork 746
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
Intl.NumberFormat.prototype.format() throws TypeError: Cannot convert BigInt to number when passed a bigint argument on Android. The same code works correctly in V8 (Chrome) and SpiderMonkey (Firefox).
- I have run
gradle cleanand confirmed this bug does not occur with JSC - The issue is reproducible with the latest version of React Native.
Hermes git revision (if applicable): bundled with React Native 0.81.5
React Native version: 0.81.5
OS: Android
Platform: arm64-v8a
Steps To Reproduce
- Create a React Native app with Hermes enabled (default for RN 0.81.5)
- Run on an Android device or emulator
- Execute any of the following:
// All three crash with: TypeError: Cannot convert BigInt to number
new Intl.NumberFormat().format(BigInt('2'))
new Intl.NumberFormat('en-US').format(BigInt('2'))
new Intl.NumberFormat().format(2n)The crash occurs regardless of whether the bigint is created via the BigInt() constructor or a bigint literal (2n), and regardless of whether a locale argument is provided.
Workaround:
new Intl.NumberFormat().format(Number(BigInt('2'))) // ✅ returns "2"The Expected Behavior
All three expressions should return "2" without throwing, as bigint is a valid argument per ECMA-402 and works correctly on V8 and SpiderMonkey.
Related open issues:
- Intl.NumberFormat can't always display the number's sign #1317 —
Intl.NumberFormatsignDisplaycan't always display sign - Intl.NumberFormat on Android with style: 'currency' and signDisplay: 'always' truncates currency sign for positive values #789 —
Intl.NumberFormatsignDisplay: 'always'truncates currency sign on Android
Reactions are currently unavailable
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't working