The following compiles without error with dmd 2.049: void main() { int i = 1; if (int i = 2) { assert(i == 2); } assert(i == 1); } It seems prohibiting such shadowing would be in line with block shadowing rules.
I'm not sure if the classification of this as enhancement is correct. The mention of the restriction is under ScopeStatement "Even though a new scope is introduced, local symbol declarations cannot shadow (hide) other local symbol declarations in the same function." but was the intent of this statement that it would apply just as well to a variable declared in an if statement? After all, it seems to me that reality its scope is that of the ScopeStatement, even though it isn't lexically within it.
Errors in D2 (2.053) but still allowed in D1 (1.068)
D1 only bug, not a spec issue.
Since this works in D2 but not D1, closing.