Skip to content

BigInt.prototype.toLocaleString() with no arguments skips default-locale grouping #7428

Description

@proggeramlug

BigInt.prototype.toLocaleString() called with no arguments does not apply the default locale's digit grouping.

const b = 12345678901234567890n;
console.log(b.toLocaleString());        // perry: 12345678901234567890
                                        // node:  12,345,678,901,234,567,890
console.log(b.toLocaleString('de-DE')); // both:  12.345.678.901.234.567.890
console.log((9876543n).toLocaleString('en-US')); // both: 9,876,543

Passing an explicit locale works correctly, so the formatter itself is fine — the no-argument path is not resolving to the default locale before formatting. Number.prototype.toLocaleString is unaffected ((1234567.891).toLocaleString() prints 1,234,567.891, matching Node), because it routes through the hand-rolled grouper in date.rs rather than intl::bigint_to_locale_string.

Reproduced on a pristine build of bd7cbb7da in a separate worktree, so this predates the current main.

Found while gating the thunk for binary size in #7427; that PR does not change this path (the ECMA-402 branch there is byte-for-byte unchanged).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions