Skip to content

Map.entries() yields [key, value] tuples, Set.entries() [value, value] - #125

Merged
ASDAlexander77 merged 1 commit into
mainfrom
map-entries-tuples
Nov 29, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
map-entries-tuples

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Map.entries() and Set.entries() give what JavaScript gives.

Validation

  • tests.ps1 passes in gc, rc, none and own (release and debug, compiled and JIT), against a compiler built from #1063.
  • Same output as Node for for (const [k, v] of m), e[0]/e[1], [...m.entries()], Set.entries() and JSON.stringify in all four models.
  • A loop of 2M rounds over both entries() is flat under rc and own (33.0 MB).

New test: tests/set_entries.ts.

🤖 Generated with Claude Code

…], 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>
@ASDAlexander77
ASDAlexander77 merged commit 8f7aa06 into main Nov 29, 2026
2 of 10 checks 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