Skip to content

fix: trait default-body placeholder overwrites real signature, breaking deriving - #83

Merged
ilyakooo0 merged 1 commit into
masterfrom
push-mukurrouztqr
Jul 13, 2026
Merged

fix: trait default-body placeholder overwrites real signature, breaking deriving#83
ilyakooo0 merged 1 commit into
masterfrom
push-mukurrouztqr

Conversation

@ilyakooo0

Copy link
Copy Markdown
Owner

Bug: Trait method with default body is monomorphic

The parser emits two TraitItem::Method entries for a method with both a signature and a default body. The skip guard in register_trait_methods tested for TypeKind::Named("_") which never matched TypeKind::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 deriving for any trait with a default body at 2+ types — a headline feature.

Fix: Match TypeKind::Hole in the skip guard (one-line fix in infer.rs).

Tests: 2 regression tests — one for trait default body, one for deriving at multiple types. All 23 regress tests pass.

…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.
@ilyakooo0 ilyakooo0 added the bug Something isn't working label Jul 13, 2026
@ilyakooo0
ilyakooo0 merged commit 34ab6dc into master Jul 13, 2026
1 check passed
@ilyakooo0
ilyakooo0 deleted the push-mukurrouztqr branch July 13, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant