Skip to content
Playground(another site)

bynk.types.cannot_infer_result_type_params

Error The type parameters of a Result could not be inferred.

Ok(v) fixes only the success type and Err(e) only the error type, so the rest of the Result has to come from context: an annotation, a parameter type, or the enclosing function's return type. A bare let r = Ok(1) has neither, and the compiler will not guess. Annotate the binding, as in let r: Result[Int, String] = Ok(1).

Example

fn run() -> Int {
let r = Ok(1) // ✗ a `Result` of what error?
1
}
fn run() -> Int {
let r: Result[Int, String] = Ok(1) // ✓
1
}

In the Book

See also

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