I've been trying to get a bunch of open source projects to compile, and a lot of the older ones have issues like:
function foo(bar) {
    do_something(bar);
    var bar = 0;
    ...
}
which results in "ERROR: Redefinition of variable 'bar'.
At first I thought the projects were just broken... but this is such a common pattern, across lots of different projects, that I'm assuming the behavior here has changed, and this used to compile successfully. Is there a hidden flag that would let it compile again?
I was also surprised to get errors for code like:
function foo(a) {
    var x = 0;
    if (a) {
        for (var x = 0; x < 10; x++) {
            // ...
        }
    }
}
While such code is asking for trouble, I'd expect more of a warning than an error.
Finally I found one interesting case thats sort of a combo:
function foo(a, i) {
    for (var i = 0; i < a.size(); i++) {
        // do something
    }
    // a is an array
    a.add(i);
}
Since I'd been mechanically fixing a few of these, my initial fix was to drop the "var" on the i in the for loop, but then we end up adding a number to the end of the array, when i was in fact a string. Doing this broke the app in such an obvious way that I have to think that at one time, this actually "worked". The i in the for loop was scoped to the for loop, and a.add(i) added the original value of i to the array.
Can anyone comment on whether the behavior really has changed? And if there are flags to get the old behavior back?
 
				 
		 
					 
				 
				 
				 
				 
				