Lyricdev
GitHub

LYR-SEM0207

a local that hides a module the file imports

warning · spec 04-modules · lint module-shadowing, group correctness, allow unless said

A local or a parameter takes the name a whole-module import binds — import std.io; binds io. Not said unless the lint is set to warn.

Explanation

Inside the local's scope the module cannot be named; a member access then means the local's member, and an error says so where it bites. The lint names the hiding itself.

Give the local another name, or import the module under another (import std.io as stdio;). The lint is allow by default.

Wrong

import std.io;

@Warn("module-shadowing")
fn main(): void {
    let io = 1;
    let _ = io;
}
import std.io;

@Warn("module-shadowing")
fn main(): void {
    let count = 1;
    let _ = count;
    io.println("x");
}