bynk.types.guard_not_bool
Error A match-arm if guard is not a Bool expression.
A guard, as in pattern if condition => …, decides whether an arm applies, so it must be a Bool: a number or an Option is not read as true or false. Say what you mean with a comparison, such as r > 10. A guarded arm covers nothing for exhaustiveness, because its guard may fail. The condition of an if expression is bynk.types.if_non_bool_cond.
Example
type Shape = | Circle(radius: Int) | Dot
fn label(s: Shape) -> String { match s { Circle(r) if r => "round" // ✗ `r` is an `Int` Circle(_) => "small" Dot => "dot" }}
fn label(s: Shape) -> String { match s { Circle(r) if r > 10 => "round" // ✓ Circle(_) => "small" Dot => "dot" }}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.guard_not_boolshows the same from the installed toolchain, without a network.