Lyricdev
GitHub

LYR-SEM0088

an overloaded interface member

error ยท spec 05-interfaces

An interface declares two members of the same name.

Explanation

A method table holds one function per slot and finds it by name, so an interface member cannot be overloaded; every conformer would owe both, under one slot.

Give the two members distinct names.

Wrong

interface Shape {
    fn scale(f: int): Self;
    fn scale(fx: int, fy: int): Self;
}

fn main(): void {
}
interface Shape {
    fn scale(f: int): Self;
    fn stretch(fx: int, fy: int): Self;
}

fn main(): void {
}