Lyricdev
GitHub

LYR-SEM0132

a conformance to a sealed interface outside its module

error · spec 05-interfaces

A type, conformance block or child interface outside the module that declares a sealed interface conforms to it — for example a program's type to 'std.sync.AtomicValue'.

Explanation

A sealed interface fixes its conformers in the module that declares it: the set is closed there, and code may rely on that — a match of type patterns over it can be exhaustive, and the library can assume each conformer's representation. A conformance from anywhere else would break that.

Use one of the interface's own conformers, or declare an interface of your own.

Wrong

import std.sync { AtomicValue };

extend string :: [AtomicValue] { }

fn main(): void {
}
fn main(): void {
}