Lyricdev
GitHub

LYR-SEM0064

a type alias that expands to itself

error ยท spec 03-types

A type alias names itself in its own definition, directly or through other aliases.

Explanation

An alias is another name for a type, expanded where it is used; an alias defined through itself never finishes expanding. The error is reported once, at the alias.

Define the recursive shape as a struct, enum or class, which may refer to itself through a reference, and alias that.

Wrong

type Tree = (int, Tree[]);

fn main(): void {
    let t: Tree = (1, []);
    let _ = t.0;
}
type Tree = (int, int[]);

fn main(): void {
    let t: Tree = (1, []);
    let _ = t.0;
}