Lyricdev
GitHub

LYR-SEM0153

a name hides one of the prelude's

warning · spec 04-modules · lint prelude-shadowing, group correctness, warn unless said

A module declares or imports a name the prelude already gives every module (assert, panic, Result, Test …); the module's own wins in that module. The standard library itself is not warned.

Explanation

Declaring or importing a name the prelude provides is legal: the module's own binding wins inside that module. It is said because a reader of assert(x) takes it for the one every module has. An import that binds the very symbol the prelude passes on hides nothing and is not warned.

Rename the declaration, or import it under another name.

Wrong

fn assert(x: bool): void {
}

fn main(): void {
    assert(true);
}
fn check(_x: bool): void {
}

fn main(): void {
    check(true);
}