LYR-SEM0206
a local that hides one of the same name
A local binding in an inner block takes the name of a local or a parameter around it. Not said unless the lint is set to warn.
Explanation
Inside the block the outer local cannot be reached by its name, and a reader may take one for the other. The language allows it — in one scope a name is bound once (LYR-SEM0176), across scopes it may be bound again.
Give the inner binding another name. The lint is allow by default.
Wrong
@Warn("shadowed-local")
fn main(): void {
let x = 1;
if (x > 0) {
let x = 2;
let _ = x;
}
}
Right
@Warn("shadowed-local")
fn main(): void {
let x = 1;
if (x > 0) {
let y = 2;
let _ = y;
}
}