test262: Object conformance fixes (wave 15) - #80
Merged
Conversation
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.
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.
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 theirtoString), 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, unlikeobj.hasOwnProperty) andObject.getPrototypeOfto 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).