Lyricdev
GitHub

LYR-SEM0047

an extend target or conversion not supported

error ยท spec 05-interfaces

An extend block targets an inline array T[N], or something that is no named type and no built-in constructor.

Explanation

An inline array has length(), isEmpty() and toArray(), and where it lies in the heap the members of a view; a block on it would add nothing reachable, so the block is written on Slice<T>. A value of an interface needs a method table for its type; for a conformance that comes only from a block on a shape or from a blanket block that table does not exist yet.

Write the block on Slice<T>; reach a blanket or shape conformance through a type parameter's constraint instead of an interface value.

Wrong

extend<T> T[4] {
    fn head(): T { return this[0]; }
}

fn main(): void {
}
extend<T> Slice<T> {
    fn head(): T { return this[0]; }
}

fn main(): void {
}