bynk.types.match_arm_mismatch
Error A match arm has a different type from the others.
A match is an expression, so its arms must produce one type: the least upper bound of their types, where a refined type and its base agree at the base. If one arm gives a String and another an Int, there is no single type for the caller to rely on. Make the arms agree, converting where needed. The rule also holds for let … else, whose else must produce the type of the rest of its block.
Example
type Status = enum { Pending, Active, Done }
fn label(s: Status) -> String { match s { Pending => "waiting" Active => 1 // ✗ an `Int`, where the others are `String` Done => "finished" }}
fn label(s: Status) -> String { match s { Pending => "waiting" Active => "running" // ✓ Done => "finished" }}In the Book
See also
- The grammar rule it governs:
match_arm. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.match_arm_mismatchshows the same from the installed toolchain, without a network.