Lyricdev
GitHub

LYR-PAR0047

'by' where nothing is delegated

error · spec 05-interfaces

An entry of the interface list of an enum, of an interface's parents, or of an extend block names a field to delegate to with by.

Explanation

Walker by legs delegates a conformance of a struct or a class to one of its fields. An enum has variants, not fields; an interface and an extend block have no fields at all — so by has nothing to name there.

Drop by and the field, and implement the members.

Wrong

interface Named {
    fn name(): string;
}

enum Color :: [Named by red] {
    Red;
    fn name(): string { return "red"; }
}

fn main(): void {
}
interface Named {
    fn name(): string;
}

enum Color :: [Named] {
    Red;
    fn name(): string { return "red"; }
}

fn main(): void {
    let _ = Color.Red.name();
}