Lyricdev
GitHub

LYR-SEM0011

a name in type position that is no type

error · spec 03-types

A type name, an initializer T { … } or an attribute names something that is not a type, or nothing at all. A non-type name before braces is also reported here, since the braces then read as an initializer's fields.

Explanation

A name in type position resolves to a struct, class, enum, interface, alias or type parameter visible at that point. A misspelling, a missing import, or a function name before { … } (where a trailing block was meant) is the usual cause.

Correct the name or import the type. For a trailing block, write its parameters before =>, and end an assignment inside it with ;.

Wrong

struct Point { x: int }

fn main(): void {
    let p = Pont { x = 1 };
    let _ = p.x;
}
struct Point { x: int }

fn main(): void {
    let p = Point { x = 1 };
    let _ = p.x;
}