Skip to content

D44: map traversal observes; keys/values/iter are view iterators; HashSet iterates; comprehensions over maps (#2183, #2184, #2185) - #2195

Merged
ehartford merged 2 commits into
d94-decl-selectfrom
d44-map-views
Oct 5, 2026
Merged

ehartford merged 2 commits into
d94-decl-selectfrom
d44-map-views

Conversation

@ehartford

@ehartford ehartford commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Layer 5 of stack #2196.

HashMap, HashSet and BTreeMap traverse through MapIter/MapKeys/MapValues/SetIter: ephemeral view iterators, so m.keys() |> map(it.clone()) |> collect[Vec]() is the owned collection D44 names. The built-in snapshot intrinsics and items() are gone. The .map(f) adapter is renamed MappedIter.

Fixed on the way:

Transfers (into_iter, into_keys, into_values, drain) are #2191.

Closes #2183, #2184, #2185, #2187, #2188, #2189, #2190.

@ehartford
ehartford added this pull request to stack #2196 October 5, 2026 19:30
@ehartford ehartford changed the title d44 map views D44: map traversal observes; keys/values/iter are view iterators; HashSet iterates; comprehensions over maps (#2183, #2184, #2185) Oct 5, 2026
Eric Hartford added 2 commits October 5, 2026 13:23
…rators; for and comprehensions over a map or set step iter() (#2183, #2184, #2185)

HashMap, HashSet and BTreeMap traverse through MapIter, MapKeys, MapValues
and SetIter: concrete ephemeral iterators over a view of the collection
whose items are views into it, so nothing is copied out (§2.3) and every
iterator adapter applies (m.keys() |> map(it.clone()) |> collect[Vec]()).
The built-in snapshot intrinsics (MAP_KEYS/VALUES/ITEMS, the cloning
lowering, with_hashmap_*_out callers) are gone, and items() with them; a
HashMap is walked through std-only slot accessors. The .map(f) adapter is
MappedIter: MapIter is the spec's name for the traversal. HashSet is
iterable (#2183); a comprehension clause over a map, set or BTreeMap steps
the collection's iter() (#2185).

Found on the way, fixed here:
- #2187: a view returned through a match arm's or let-else's pattern
  binding lost its parameter origin, so a use-after-free compiled. The
  tail view's parameter effects are now published in scope; the origin
  walkers read each match arm's frozen facts; a place reached through a
  view of a view (and a view payload bound out of a by-value subject)
  views what the inner view views; record_transparent_view_origins reads
  a node's storage before resetting it.
- #2188: reflecting a generic instance resolved its template by a name
  visible from the current module; a private generic enum reached through
  another module's type ICEd. It reads the instance's recorded template.
- #2189: indexing through &&Vec[T] peels every reference.
- #2190: collect[String]() frees its staging Vec.

The transferring traversals (into_iter, into_keys, into_values, drain)
are #2191.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on the stack top a21e326 (stack #2196): gate rc=0 (102s), uat rc=0 (73s), battery-checks rc=0 (245s); green evidence published.

@ehartford
ehartford marked this pull request as ready for review October 5, 2026 20:31
@ehartford
ehartford merged commit efb765c into main Oct 5, 2026
@ehartford
ehartford deleted the d44-map-views branch October 5, 2026 20:31
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.

for n in set: HashSet is not iterable

1 participant