LYR-SEM0176
a name is bound twice in one scope
A let or var binds a name that the same block already binds, or a name of a parameter directly in the function body's block. _ binds nothing and is exempt.
Explanation
A name is bound once in a scope; a parameter counts as bound in the body's own block. A second binding there would hide the first in the middle of a block, and a reader could not tell which one a later use means. A nested block may still bind a name that an outer scope binds.
Give the second binding another name, or put it in a block of its own.
Wrong
fn main(): void {
let x = 1;
let x = x + 1;
assert(x == 2);
}
Right
fn main(): void {
let x = 1;
let y = x + 1;
assert(y == 2);
}