Lyricdev
GitHub

LYR-SEM0209

a block's implicit 'it' that hides the 'it' around it

warning · spec 08-expressions · lint shadowed-it, group correctness, warn unless said

A trailing block that uses its implicit it stands inside another trailing block with an implicit it.

Explanation

Inside the inner block it is the inner block's parameter; the outer one cannot be named, and a reader may take one for the other.

Name the parameter of one of them: apply { x => apply { it + 1 } + x }.

Wrong

fn apply(f: fn(int) -> int): int {
    return f(1);
}

fn main(): void {
    let _ = apply { apply { it + 1 } + it };
}
fn apply(f: fn(int) -> int): int {
    return f(1);
}

fn main(): void {
    let _ = apply { x => apply { it + 1 } + x };
}