Hi,
I’m trying out Odin and there is a behavior I don’t understand concerning variable shadowing.
If we have the following code, we have an error because the local variable i
shadows the return parameter i
:
foo :: proc() -> (i: i32) {
i := 3 // error
return
}
However, when the variable i
is declared in a sub-scope, the error disappears:
foo :: proc() -> (i: i32) {
{
i := 83 // no error ?
fmt.println(i)
}
return
}
The behavior is the same with local variables (it doesn’t have to be a return value).
Since Odin doesn’t allow shadowing in the same scope (unless for explicit parameter modification), I think it’s strange to allow it in sub-scopes. For me, shadowing should be, either allowed everywhere, or not at all (I personally prefer not). Is there a use case for this that I’m missing, or is it a bug?