Skip to content
Playground(another site)

bynk.types.type_mismatch

Error An operator or built-in method got an operand of a type it does not accept, or two operands that had to match did not.

An operator or a built-in method was given an operand of a type it does not accept: == between an Int and a String, ! on a number, && on something that is not a Bool. Types are compared exactly, with no implicit conversion, so values of different types are never equal and never silently coerced. Make the operands the same type, or convert one explicitly. A Float and an Int mixed in arithmetic is the separate code bynk.types.no_numeric_coercion.

Example

fn isAdult(age: Int) -> Bool {
age == "18" // ✗ `Int` compared with `String`
}
fn isAdult(age: Int) -> Bool {
age == 18 // ✓ both `Int`
}

In the Book

See also

  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.type_mismatch shows the same from the installed toolchain, without a network.