fix(runtime): Array.isArray/from/of usable as first-class function values#4626
Merged
Conversation
…lues Same reroute-undo issue as Date.now (#4622): value reads of Array.isArray / Array.from / Array.of collapsed to GlobalGet(0).<name>, whose intrinsic path drops the function metadata — typeof was 'function' but .name was undefined and .length undefined. They are installed with metadata via install_constructor_static, so add Array to the reified-static reroute-undo exception. Array.fromAsync is unreified and unchanged; direct calls keep the intrinsic fast path via the !member_is_call_callee gate. Byte-identical to node: Array.isArray.name==='isArray'/.length===1, Array.from.name==='from'/.length===1, Array.of.name==='of'/.length===0, value-calls and direct calls work. Fixes test262 Array/{isArray,from,of}/{name,length}.
proggeramlug
added a commit
that referenced
this pull request
Jun 5, 2026
…nction values (#4631) Same reroute-undo issue as Date.now (#4622) / Array.isArray (#4626). All six Number statics (isFinite/isInteger/isNaN/isSafeInteger/parseFloat/parseInt) are reified with metadata via install_constructor_static, but the #973/#4139 reroute-undo collapsed value reads to GlobalGet(0).<name>, whose intrinsic path dropped the metadata for isInteger/isSafeInteger (.name/.length undefined). Add Number to the reified-static reroute-undo exception. The already-named siblings (isFinite/isNaN/parseFloat/parseInt) are also reified, so routing them to the reified receiver preserves their names; direct calls keep the intrinsic fast path via the !member_is_call_callee gate. Byte-identical to node: Number.isInteger.name==='isInteger'/.length===1, isSafeInteger likewise; value-calls and direct calls work. Fixes test262 Number/{isInteger,isSafeInteger}/{name,length}. (String.fromCharCode/etc. are not reified yet — tracked in #4627.) Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug
added a commit
that referenced
this pull request
Jun 5, 2026
… function values (#4634) Completes the static-function-values series (#4622 Date, #4626 Array, #4631 Number). Unlike those, String.fromCharCode/fromCodePoint were not reified at all, so this both reifies them and wires the reroute-undo exception: - New js_string_from_code_point_array runtime helper (variadic fromCodePoint with per-element RangeError validation; lone surrogates → U+FFFD). - Reify fromCharCode/fromCodePoint via install_constructor_static_with_call_arity (call-arity 0 = all args into rest; spec .length 1) — fromCharCode reuses the existing js_string_from_char_code_array. - Explicit String fromCharCode/fromCodePoint exception in the #973/#4139 reroute-undo (NOT the whole namespace — String.raw is not reified and stays on its intrinsic path, unaffected). Byte-identical to node: typeof/name/length, value-calls (incl. astral code points), direct calls, RangeError on invalid code points; String.raw unchanged. Fixes test262 String/{fromCharCode,fromCodePoint}/{name,length}. (String.raw .name /.length tracked in #4627.) Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug
added a commit
that referenced
this pull request
Jun 5, 2026
Completes the static-function-values series (Date #4622, Array #4626, Number #4631, String.fromCharCode/fromCodePoint #4634). Reify String.raw as a real function value: a thunk taking the template/cooked object as a fixed param plus a rest of substitutions (call-arity 1, spec .length 1), forwarding to js_string_raw. Add 'raw' to the String reroute-undo exception so value reads hit the reified receiver. Byte-identical to node: String.raw.name==='raw'/.length===1, value-calls (const r=String.raw; r({raw:[...]}, ...)) and tagged-template calls (String.raw`x${10}y`) work. Fixes test262 String/raw/{name,length}; closes the String portion of #4627. Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug
added a commit
that referenced
this pull request
Jun 6, 2026
…4521) (#4658) Continues the static-function-values series (#4622 Date, #4626 Array, #4631 Number, #4634 String) for the Promise constructor. Promise.all / race / allSettled / any / resolve / reject / withResolvers / try were not reified at all, so reading them as values gave undefined (typeof undefined, no .name / .length, not callable via reference / .call / .apply). - Reify all eight statics via install_constructor_static[_with_call_arity] in install_builtin_constructor_statics ("Promise" arm). They delegate to the same runtime entry points the direct-call codegen path emits, so behavior is unchanged for direct calls; value reads and rebound usage now resolve to real native function objects with spec .name / .length (all combinators + resolve / reject / try = 1, withResolvers = 0), prop-desc {writable, !enumerable, configurable}, and non-constructor semantics (new Promise.all([]) throws TypeError). - Wire the #973/#4139 reroute-undo exception in expr_member.rs so value reads of these members keep the reified Promise receiver instead of collapsing to GlobalGet(0).<name> (undefined). Direct calls keep the codegen fast path via the !member_is_call_callee gate. Byte-identical to node: typeof / name / length / prop-desc, not-a-constructor throws, value-calls and .call(Promise, ...) for every combinator, withResolvers and try. Verified under both the runtime-only and auto-optimize build paths. Existing direct-call combinators and then/catch/finally/await unchanged. test262 built-ins/Promise/all parity 52.1% -> 55.2%; fixes the name / length / prop-desc / not-a-constructor cases across all four combinator dirs. Spec-internal observable semantics (per-iteration this.resolve, real resolve-element closures with [[AlreadyCalled]], NewPromiseCapability(this)) are a follow-up: they require dynamic `new <Promise-bound>(executor)` (today throws "Promise is not a function") and routing the direct-call path through the constructor-aware algorithm. Co-authored-by: Ralph Küpper <ralph@skelpo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4622 (Date statics), same root cause. Value reads of
Array.isArray/Array.from/Array.ofwere collapsed by the #973/#4139 reroute-undo toGlobalGet(0).<name>, whose intrinsic path drops the function metadata —typeofwas "function" but.nameand.lengthwereundefined.These are installed with metadata via
install_constructor_static(global_this.rs:3558-3567), so addArrayto the reified-static reroute-undo exception.Array.fromAsyncis unreified and unchanged; direct calls keep the intrinsic fast path via the!member_is_call_calleegate.Byte-identical to
node --experimental-strip-types:Value-calls (
const f = Array.from; f([1,2,3])) and direct calls work. Fixes test262built-ins/Array/{isArray,from,of}/{name,length}(6 tests).(Number/String have the same gap but only partial static reification, so they need explicit per-member handling — deferred to a follow-up.)