Repository navigation
Map.entries() yields [key, value] tuples, Set.entries() [value, value] - #125
Merged
Merged
Conversation
…], as in JavaScript
- Map's entries were a labelled tuple, `[key: K, value: V]`, which JSON.stringify wrote as
`{"key": ..., "value": ...}`, not `["a", 1]`; and code could read `entry.key`, which tsc rejects.
They are `[K, V]` now. tests/map_entries.ts read `.key`/`.value`: it reads `[0]`/`[1]`.
- Set.entries() returned the values iterator: `for (const [a, b] of s.entries())` took a string
apart into its characters. It yields `[value, value]` (iterEntries), reading the field twice:
one value put into the tuple twice was freed twice under -mm=own by compilers before TSLANG 225.
Test tests/set_entries.ts. tests.ps1 passes in gc, rc, none and own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Map.entries()andSet.entries()give what JavaScript gives.[key: K, value: V].JSON.stringify([...m.entries()])wrote[{"key":"a","value":1}, ...]instead of[["a",1], ...], andentry.keycompiled, which tsc rejects. They are[K, V]now.tests/map_entries.tsread.key/.valueand now reads[0]/[1].entries()returned the values iterator, sofor (const [a, b] of s.entries())took a string apart into its characters. It yields[value, value]now. The value is read from the field twice: compilers before TSLANG 225 (TSLANG 225: own counts a local holding a global's value; --own-fallback=count counts an object two constructors keep; Debug parse-op asserts TypeScriptCompiler#1063) freed one value put into a tuple twice under-mm=own.Validation
tests.ps1passes in gc, rc, none and own (release and debug, compiled and JIT), against a compiler built from #1063.for (const [k, v] of m),e[0]/e[1],[...m.entries()],Set.entries()andJSON.stringifyin all four models.entries()is flat under rc and own (33.0 MB).New test:
tests/set_entries.ts.🤖 Generated with Claude Code