bynk.types.is_literal_pattern
Error A literal was used on the right of is; is tests type/refinement, not value equality (use ==).
is tests a value's variant or refined type, not its value, so x is 31 would read as a type test while meaning equality. Bynk refuses it rather than let the two readings blur. Compare with == instead. In a match, a literal is a fine pattern, because a match arm tests a value there.
Example
fn thirty(x: Int) -> Bool { x is 31 // ✗ `is` tests a type, not a value}
fn thirty(x: Int) -> Bool { x == 31 // ✓}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_literal_patternshows the same from the installed toolchain, without a network.