Skip to content

test262: Object conformance fixes (wave 15) - #80

Merged
hiett merged 1 commit into
experiment/js-frontendfrom
js262/wave15-Object
Jul 15, 2026
Merged

test262: Object conformance fixes (wave 15)#80
hiett merged 1 commit into
experiment/js-frontendfrom
js262/wave15-Object

Conversation

@hiett

@hiett hiett commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Adds two Object statics, matching the ECMAScript spec.

Object.groupBy (sec-object.groupby)

New runtime object_group_by/2: groups an iterable's elements into a fresh null-prototype object keyed by ToPropertyKey(callback result) (ToPrimitive→ToString, so numeric keys become strings and objects contribute their toString), each key's elements collected into an Array in encounter order. A non-callable callback throws a TypeError before any element is read (GroupBy step 2).

test262 built-ins/Object/groupBy: 0 → 5 pass. The lone remaining fail_assert (evenOdd) is the pre-existing, documented object-key-ordering deviation (Object.keys follows backing-map order, not first-encounter order) — not fixable without touching the shared obj_pairs helper, which is out of scope.

Object.hasOwn (sec-object.hasown) + Object.getPrototypeOf

Routed the static Object.hasOwn(obj, key) to the existing own-property op (works with null-prototype receivers, unlike obj.hasOwnProperty) and Object.getPrototypeOf to the shared prototype op. Contributed 7 new passes in built-ins/Object/hasOwn.

Spec-driven tests appended at EOF of js_compiler_test.gleam under the wave-15 header. js_compiler_test fully green (only the 3 pre-existing WASM .wat fixture failures remain).

Implement Object.groupBy (sec-object.groupby): group an iterable's elements
into a fresh null-prototype object keyed by ToPropertyKey(callback result),
with each key's elements collected into an Array in encounter order. A
non-callable callback throws a TypeError before any element is read (GroupBy
step 2). Route the static Object.hasOwn(obj, key) (sec-object.hasown) to the
existing own-property runtime op so it works with null-prototype receivers,
and Object.getPrototypeOf(obj) to the shared prototype op (null in this
prototype-less model).

Adds spec-driven tests covering bucketing, numeric/toString key coercion,
the null prototype, the non-callable TypeError, and Object.hasOwn.
@hiett
hiett merged commit 39519a7 into experiment/js-frontend Jul 15, 2026
1 check passed
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