Lyricdev
GitHub

LYR-PAR0064

a field that ends with ';'

error · spec 16-diagnostics

A field of a struct or class, or a field of an initializer, ends with ; where its list separates with ,; read as the , it stands for.

Explanation

The fields of a type and the fields of an initializer are lists, and a list separates its items with ,. A ; ends a statement. The compiler reads the ; as the , it stands for, says it once where it stands, and goes on: the next field is read as it is written. After the name of a type, braces that hold name = value; are an initializer, not a call with a trailing block.

lyric fix writes , — after the last field of an initializer it takes the ; out.

Wrong

struct Pair {
    a: int;
    b: int,
}

fn main(): void {
}
struct Pair {
    a: int,
    b: int,
}

fn main(): void {
}