Lyricdev
GitHub

LYR-SEM0077

an import that shadows a builtin type

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

An import binds a name that is also a builtin type, such as import std.string; binding string.

Explanation

A name an import binds shadows the builtin scope, so after import std.string; the annotation string names the module, not the type. It is legal and almost never meant.

Import the names you need selectively (import std.string { fromInt };), or rename the binding with as.

Wrong

import std.string;

fn main(): void {
    let _ = string.fromInt(42);
}
import std.string { fromInt };

fn main(): void {
    let _ = fromInt(42);
}