bynk.generics.uninferable_type_arg
Error A generic function's type parameter could not be inferred from the arguments and was not given explicitly (name[T](…)); a bare generic function also cannot be passed as a value.
A call to a generic function leaves a type parameter undetermined. Bynk fixes a type parameter from the arguments and, failing that, from the type the call is expected to have; it never guesses. none() has no argument that mentions T, and let x = none() gives it no expected type, so there is nothing to choose T from. The error also fires when a lambda's parameter types depend on a parameter that the other arguments leave open. Give the type argument explicitly with none[Int](), or annotate the binding so the expected type supplies it: let x: Option[Int] = none().
Example
fn none[T]() -> Option[T] { None}
let x = none() // ✗ nothing says what `T` is
let x = none[Int]() // ✓ given explicitlyIn the Book
See also
- The grammar rule it governs:
call. - Every code in its category, Generics, on the diagnostic index.
bynk explain bynk.generics.uninferable_type_argshows the same from the installed toolchain, without a network.