Esc

shadowed_local

Finds a local variable named like a parameter or another local in an enclosing scope of the same procedure.

Category pedantic, allow by default.

Off by default; the example is shown with the rule enabled.

Example
#import "Basic";

clamp_count :: (count: int) -> int {
    if count > 10 {
        count := 10;
        return count;
    }

    return count;
}

main :: () {
    print("%\n", clamp_count(12));
}
Diagnostic
warning[shadowed_local]: `count` shadows the variable of that name declared on line 3
  --> example.jai:5:9
   |
 5 |         count := 10;
   |         ^^^^^
   |
   = help: rename one of them; an assignment here no longer reaches the outer one
Fixed
#import "Basic";

clamp_count :: (count: int) -> int {
    if count > 10 {
        capped := 10;
        return capped;
    }

    return count;
}

main :: () {
    print("%\n", clamp_count(12));
}

A variable declaration (name := ..., name: T) in a nested block, loop body or case body whose name is a parameter or a variable declared earlier in an enclosing block of the same procedure.