LYR-SEM0026
the wrong number of type arguments
A generic type, alias or function is given more or fewer type arguments than it declares type parameters (after defaults), or a function that is not generic is given type arguments.
Explanation
Cell<T> takes one type argument and Pair<A, B> two; a type parameter with a default may be left out. A function that is not generic takes none.
Write as many type arguments as the declaration has parameters, or leave them out where the context or the arguments determine them. A call writes them all or none: _ stands for one the inference is to fill — arrayOf<string, _>(3, f) writes T and leaves E, what f throws, to the call. Where a call writes too few, lyric fix adds a _ for each one left out.
Wrong
struct Cell<T> { v: T }
fn main(): void {
let b: Cell<int, int> = Cell { v = 1 };
let _ = b.v;
}
Right
struct Cell<T> { v: T }
fn main(): void {
let b: Cell<int> = Cell { v = 1 };
let _ = b.v;
}