Skip to content

Implement Dict builtins and related fixes#9414

Merged
Anton-4 merged 4 commits into
mainfrom
implement-dict-builtin
May 14, 2026
Merged

Implement Dict builtins and related fixes#9414
Anton-4 merged 4 commits into
mainfrom
implement-dict-builtin

Conversation

@Anton-4
Copy link
Copy Markdown
Collaborator

@Anton-4 Anton-4 commented May 13, 2026

No description provided.

Anton-4 and others added 4 commits May 11, 2026 17:38
Polymorphic functions whose return type is a nominal containing rigids
(like `Dict(k, v)` in `Dict.from_list`) crashed the interpreter with an
`e_tag: expected tag_union but got rt=err` error. Three interacting
issues in runtime type translation:

- `collectRigidsFromType` didn't recurse into nominal_type args, so
  rigids nested inside another nominal (e.g. k, v inside `List((k, v))`
  in Dict's backing) were never found, leaving the backing disconnected
  from the call site's type args.
- Nested nominal translations cleared `translate_rigid_subst`,
  clobbering the outer scope's mappings — now snapshot/restore around
  each nominal_type translation.
- `putFlexTypeContext` only bumped the polymorphic-context generation
  on value changes, not on new entries. Cached translations from before
  a polymorphic body's `propagateFlexMappings` ran were returning stale
  rigid translations; bump on new entries too.

Add a snapshot test for `Dict.from_list`. Update the `List.repeat -
empty case` test, which previously relied on the stale-cache behavior
to produce a `.list_of_zst` layout — with the fix the element type
resolves correctly, so the empty list has a proper `.list` layout with
the I64 element layout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When resolving a method's type variables against the receiver, the
interpreter walked the return type and receiver type in parallel — fine
for `T(s) -> T(s)`, but for `Dict(k, v) -> List(v)` it aligned `List`'s
single arg with `Dict`'s first arg, leaving `v -> Str` in
flex_type_context and breaking the subsequent match on `Pairs(list)`.

Gate the return-to-receiver propagation on a matching nominal head so
the misalignment can't happen.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Anton-4 Anton-4 merged commit 225c249 into main May 14, 2026
39 checks passed
@Anton-4 Anton-4 deleted the implement-dict-builtin branch May 14, 2026 09:33
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