test262: MapSet conformance fixes (wave 13) - #74
Merged
Conversation
Add the Map.groupBy static method: iterate the items argument through the iterator protocol (arrays, strings by code point, Sets/Maps/generators) and collect each element into a fresh Map keyed by callbackfn(value, index). Key equality is SameValueZero via mapkey_norm (COLLECTION coercion) so -0 folds to +0, but no ToPropertyKey conversion is applied, keeping a number key distinct from the equal string key. A non-callable callbackfn raises a TypeError before any element is visited (GroupBy step 2). Clears the six Map/groupBy test262 runtime failures (evenOdd, groupLength, map-instance, negativeZero, string, toPropertyKey).
…p 3) Map.prototype.getOrInsertComputed (and the WeakMap form) must throw a TypeError when callbackfn is not callable, and the IsCallable check runs BEFORE the key lookup so it fires even when the key is already present (the callback would otherwise never be invoked). Previously the check was absent, so a present key silently skipped the throw and an absent key crashed with badarg when trying to call a non-function. Fixes Map/prototype/getOrInsertComputed/not-a-function-callbackfn-throws.
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.
Two spec-driven fixes for the Map/Set built-in family.
Map.groupBy (sec-map.groupby)
Implements the static
Map.groupBy(items, callbackfn): iterate the iterable through the iterator protocol (arrays, strings by code point, Sets/Maps/generators), callcallbackfn(value, index), and collect elements into a new Map keyed by the result. Key equality is SameValueZero via mapkey_norm (COLLECTION coercion) —-0folds to+0, but no ToPropertyKey conversion, so a number key stays distinct from the equal string key. Non-callable callbackfn throws TypeError before visiting any element (GroupBy step 2). Clears the 6 Map/groupBy runtime failures (evenOdd, groupLength, map-instance, negativeZero, string, toPropertyKey).getOrInsertComputed non-callable check (upsert proposal step 3)
Map.prototype.getOrInsertComputed(and the WeakMap form) now throws TypeError for a non-callable callbackfn, with the IsCallable check ordered BEFORE the key lookup so it fires even when the key is already present. Previously a present key skipped the throw and an absent key crashed with badarg. Fixes getOrInsertComputed/not-a-function-callbackfn-throws.Impact
Map+Set test262: pass 270 -> 277, runtime_error 16 -> 9. All js_compiler_test green; 8 new spec-driven tests appended under the wave-13 header.