Skip to content
Playground(another site)

bynk.types.if_non_bool_cond

Error An if condition is not a Bool.

An if chooses a branch on a Bool, and Bynk has no truthiness: a number, a string, an Option or a list is never read as true or false. Say what you mean with a comparison (count > 0), or test an Option with is Some(…). A match-arm guard has the same rule, as bynk.types.guard_not_bool.

Example

fn describe(count: Int) -> String {
if count { "some" } else { "none" } // ✗ an `Int`, not a `Bool`
}
fn describe(count: Int) -> String {
if count > 0 { "some" } else { "none" } // ✓
}

In the Book

See also

  • The grammar rule it governs: if_expr.
  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.if_non_bool_cond shows the same from the installed toolchain, without a network.