bynk.generics.type_arg_mismatch
Error Inferred or explicit type arguments conflict, have the wrong arity, target a non-generic function, or a type parameter shadows a declared type.
The type arguments of a generic call do not fit. The checker infers each type parameter from the arguments, and an argument that contradicts what an earlier one settled is refused: pick(1, "one") cannot make T both Int and String. The same code covers explicit type arguments of the wrong number (pick[Int, Int](…)), type arguments given to a function that is not generic, and a type parameter named like a declared type. Make the arguments agree, give the type argument explicitly where the inference is not what you meant, or rename the parameter.
Example
fn pick[T](a: T, b: T) -> T { a}
let x = pick(1, "one") // ✗ `T` is `Int` from the first argument
pick(1, 2) // ✓ both arguments are `Int`In the Book
See also
- The grammar rule it governs:
call. - Every code in its category, Generics, on the diagnostic index.
bynk explain bynk.generics.type_arg_mismatchshows the same from the installed toolchain, without a network.