Lyricdev
GitHub

LYR-SEM0175

'opaque type' is no form of Lyric 5

error · spec 03-types

A declaration is written opaque type Name = …;, the 4.x form.

Explanation

Lyric 5 has no opaque type alias. A struct of one field takes its place: it is a type of its own, distinct from the field's type, and has the layout of its field.

Write struct Name { value: … }.

Wrong

opaque type Meters = float;

fn main(): void {
}
struct Meters {
    value: float,
}

fn main(): void {
    let m = Meters { value = 2.5 };
    assert(m.value > 0.0);
}