Skip to content

fix(runtime): obj.toLocaleString runtime dispatch + async-gen 0-arg return/throw arity - #4546

Merged
proggeramlug merged 1 commit into
mainfrom
fix-tolocalestring-asyncgen
Jun 5, 2026
Merged

fix(runtime): obj.toLocaleString runtime dispatch + async-gen 0-arg return/throw arity#4546
proggeramlug merged 1 commit into
mainfrom
fix-tolocalestring-asyncgen

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Two test262/parity fixes

1. value.toLocaleString() on non-number receivers (#4546)

The Expr::DateToLocaleString codegen arm routed every non-number receiver to js_date_to_locale_string, so a plain object / string / boolean printed a 1970-epoch "Invalid Date" instead of [object Object] (or a custom toLocaleString).

Fix: new js_value_to_locale_string runtime helper that dispatches on the value tag (number → grouping, Date → date string, object → custom/[object Object]). The unknown-static-type arm now calls it; Number/Int32 keep their fast path; dates flow through the runtime tag check.

({}).toLocaleString()        // before: "Invalid Date"  → now: "[object Object]"
"hi".toLocaleString()        // before: "Invalid Date"  → now: "hi"
true.toLocaleString()        // before: "Invalid Date"  → now: "true"
[1,2,3].toLocaleString()     // "1,2,3"  (unchanged)
(12345.6).toLocaleString()   // "12,345.6"  (unchanged, #600/#3917)

2. async-generator 0-arg .return() / .throw() (#4547)

The queue wrappers (next/return/throw) each take one arg but had no registered arity, so a 0-arg gen.return() / gen.throw() read an uninitialized stack slot instead of undefined. Register arity 1 for the three wrapper func pointers.

All cases above verified byte-identical against node --experimental-strip-types.

…eturn/throw arity

value.toLocaleString() on a non-number receiver was mis-routed by the
Expr::DateToLocaleString codegen arm to js_date_to_locale_string, printing
a 1970-epoch "Invalid Date" for plain objects/strings/booleans. Add a
js_value_to_locale_string runtime helper that dispatches on the value tag
(number grouping, Date string, object custom/[object Object]) and route the
unknown-static-type arm to it.

Async-generator next/return/throw queue wrappers each take one arg but had
no registered arity, so 0-arg gen.return()/gen.throw() read an
uninitialized stack slot instead of undefined. Register arity 1 for the
three wrapper func pointers.
@proggeramlug
proggeramlug merged commit 019a23a into main Jun 5, 2026
13 checks passed
@proggeramlug
proggeramlug deleted the fix-tolocalestring-asyncgen branch June 5, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant