Lyricdev
GitHub

LYR-SEM0063

a generic type named without its type arguments

error ยท spec 03-types

A static member, constant or variant of a generic type is reached through the bare type name, where nothing supplies the type arguments.

Explanation

Grid.size names a member of Grid<T> without saying which T. Where a call's arguments or the expected type can determine the arguments, they are inferred; a constant, a function value or a variant read on its own has nothing to infer them from.

Write the type arguments: Grid<int>.size.

Wrong

struct Grid<T> {
    cells: T[],
    static let size: int = 4;
}

fn main(): void {
    let _ = Grid.size;
}
struct Grid<T> {
    cells: T[],
    static let size: int = 4;
}

fn main(): void {
    let _ = Grid<int>.size;
}