Implement Dict builtins and related fixes#9414
Merged
Merged
Conversation
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>
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.
No description provided.