Lyricdev
GitHub

LYR-SEM0129

an associated type answer that no interface asks for

error · spec 05-interfaces

A type or conformance block declares 'type Name = …;' and no interface it conforms to there declares an associated type 'Name'.

Explanation

type Item = int; inside a struct, class, enum or conformance block answers an interface's associated type. There is no free-standing member type: where no interface of the type asks for Item, the answer answers nothing — usually the conformance it belongs to is missing or misspelled.

Add the conformance the answer is meant for, or drop the line (a module-level type alias names a type).

Wrong

struct Stray {
    type Item = int;
    v: int,
}

fn main(): void {
}
struct Stray {
    v: int,
}

fn main(): void {
}