Lyricdev
GitHub

LYR-SEM0079

an interface member inherited twice or redeclared

error ยท spec 05-interfaces

An interface inherits a method of one name from two different parents, or declares a member with the name of one it inherits.

Explanation

A method table holds one function per name, and an inherited member keeps the interface that declared it. Two parents declaring the same name would need one slot to hold two methods, and no rule picks the right one; a redeclaration would hide the parent's. The same declaration reached twice through a diamond is fine.

Rename one of the two members.

Wrong

interface Named {
    fn name(): string;
}

interface Titled {
    fn name(): string;
}

interface Labelled :: [Named, Titled] {
}

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

interface Titled {
    fn title(): string;
}

interface Labelled :: [Named, Titled] {
}

fn main(): void {
}