Here is a good explanation of what is happening, it is part of the language specification. Objective-C, Java, and C seem to have the same limitations. You can get around this by concluding your statements like this.
while(true) {int a;} if(true) {int a;} if(true) {int a = 5;} if(true) {int a = somestaticfunction();}
source share