bynk.generics.type_arg_count
Error A user-declared generic type is applied to the wrong number of type arguments, or a generic type is named without its […] arguments (v0.157, ADR 0183).
A generic type is applied to exactly as many type arguments as it declares parameters: Box[T] takes one. Too many, too few, arguments on a type that is not generic, and a generic type named with no arguments at all are all refused, since each argument fills one parameter. A type parameter such as T is not itself generic, so T[Int] is refused too. Give the arguments the declaration asks for.
Example
type Box[T] = { value: T }
fn open(b: Box[Int, String]) -> Int { // ✗ `Box` takes one type argument 0}
fn open(b: Box[Int]) -> Int { // ✓ 0}In the Book
See also
- The grammar rule it governs:
applied_type_ref. - Every code in its category, Generics, on the diagnostic index.
bynk explain bynk.generics.type_arg_countshows the same from the installed toolchain, without a network.