S0050: pattern type does not match scrutinee
Generated from rellum-diagnostics/src/db.rs.
Explanation
Record and enum patterns name the concrete type they destructure. The pattern type must be the same named type as the match scrutinee so field positions, variant tags, and payload layouts are unambiguous.
Common causes
- matching a value of one record type with a pattern for another record type
- using an enum variant pattern from the wrong enum
- renaming a type but leaving an old pattern name behind
Canonical fixes
- change the pattern to use the scrutinee's type
Before:
match point
Size { width } => width
After:
match point
Point { x } => x
- convert to the intended type before matching
Code example
match point
Size { width } => width