Lyricdev
GitHub

LYR-SEM0052

a type, module or generic function used as a value

error · spec 03-types

A name that is not a value — a type, a module, an interface — stands where a value is wanted, or the bare name of a generic function is used as a function value.

Explanation

A type is built (T { … }, T.new(…)) and a module is reached through (m.f()); neither is a value itself. A function value is monomorphic, so a generic function becomes one only with its type arguments written or by a call.

Build a value of the type, call the function, or write the type arguments (ident<int>).

Wrong

fn ident<T>(x: T): T { return x; }

fn main(): void {
    let f = ident;
    let _ = f;
}
fn ident<T>(x: T): T { return x; }

fn main(): void {
    let f = ident<int>;
    let _ = f(1);
}