Skip to content
Playground(another site)

bynk.types.is_non_sum

Error is was applied to a value that is not a sum type.

value is Variant asks which variant a sum, Result or Option holds, so its left side must be one of those. On an Int, a String or a record there is no variant to ask about. To test a number or a string against a refined type, name that type: n is Quantity. To compare by value, use ==. A variant the sum does not have is bynk.types.is_unknown_variant.

Example

type Light = | Red | Green
fn ready(n: Int) -> Bool {
n is Green // ✗ `n` is an `Int`, not a `Light`
}
fn ready(l: Light) -> Bool {
l is Green // ✓
}

In the Book

See also

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