Skip to content
Playground(another site)

bynk.types.some_value_mismatch

Error A Some payload has the wrong type.

Some(v) takes its type from the surrounding Option[T], the annotation or the function's return type, so Some("a") where T is Int is refused at the value, with no conversion. Pass a T, or change the declared type. With nothing to say what the Option holds, a bare None is bynk.types.cannot_infer_option_type_param.

Example

fn first() -> Option[Int] {
Some("a") // ✗ a `String`, where `Int` is expected
}
fn first() -> Option[Int] {
Some(1) // ✓
}

In the Book

See also

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