Skip to content

Intl.NumberFormat.format() throws "Cannot convert BigInt to number" when passed a bigint on Android #1928

@brien-crean

Description

@brien-crean

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 clean and 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

  1. Create a React Native app with Hermes enabled (default for RN 0.81.5)
  2. Run on an Android device or emulator
  3. 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:

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions