Skip to content
Playground(another site)

bynk.types.is_unknown_variant

Error is names a variant the type does not have.

l is Amber asks whether a Light is its Amber variant, which only means something if Light has one. A name that is not a variant of the sum is usually a typo or a variant left over from an earlier version of the type. Use one the type declares. On a value that is not a sum at all, the error is bynk.types.is_non_sum.

Example

type Light = | Red | Green
fn ready(l: Light) -> Bool {
l is Amber // ✗ `Light` has no variant `Amber`
}
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_unknown_variant shows the same from the installed toolchain, without a network.