LYR-SEM0200
a type parameter that is never used
A function's type parameter is named nowhere in it — not in a parameter, the result or the body. A type's is not reported: a phantom parameter only the type's name uses is a type's own.
Explanation
A type parameter nothing names cannot be inferred from a call: every caller must write it, and it changes nothing.
Take it out, or name it where the declaration needs it. A name that begins with _ is not reported.
A type's parameter is not looked at: struct Id<T> { raw: int } makes Id<User> and Id<Order> two types though nothing in Id names T.
Wrong
fn first<T, U>(xs: T[]): T {
return xs[0];
}
fn main(): void {
let _ = first<int, string>([1, 2]);
}
Right
fn first<T>(xs: T[]): T {
return xs[0];
}
fn main(): void {
let _ = first([1, 2]);
}