Lyricdev
GitHub

LYR-RES0002

a type name that names no type

error · spec 04-modules

A type annotation names a type that is neither declared in the module, imported, a builtin, nor passed on by the prelude.

Explanation

A type is found where a value's name is: in the module itself, among its imports, among the builtin types and in what the prelude passes on. Everything else of the standard library — Any, for example — is imported like any other module's name.

Declare the type, import it (import std.core { Any };), or correct the spelling.

Wrong

fn area(s: Shape): int {
    return s.side * s.side;
}

fn main(): void {
}
struct Shape {
    side: int
}

fn area(s: Shape): int {
    return s.side * s.side;
}

fn main(): void {
    assert(area(Shape { side = 2 }) == 4);
}