fix: trait default-body placeholder overwrites real signature, breaking deriving - #83
Merged
Conversation
…ng deriving
The parser emits two TraitItem::Method entries for a method with both
a signature and a default body: the signature (TypeKind::Named) and a
placeholder (TypeKind::Hole). The skip guard in register_trait_methods
tested for TypeKind::Named("_") which never matched TypeKind::Hole,
so the placeholder overwrote the real signature with an unquantified
type variable. The first call site pinned it; the second failed with
'type mismatch'. This also broke deriving for any trait with a default
body at 2+ types.
Fix: match TypeKind::Hole in the skip guard. Two regression tests.
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.
Bug: Trait method with default body is monomorphic
The parser emits two
TraitItem::Methodentries for a method with both a signature and a default body. The skip guard inregister_trait_methodstested forTypeKind::Named("_")which never matchedTypeKind::Hole(the actual placeholder type), so the placeholder overwrote the real signature with an unquantified type variable shared across all call sites.Impact: First call site pins the type; second fails with "type mismatch". Also breaks
derivingfor any trait with a default body at 2+ types — a headline feature.Fix: Match
TypeKind::Holein the skip guard (one-line fix ininfer.rs).Tests: 2 regression tests — one for trait default body, one for deriving at multiple types. All 23 regress tests pass.