It seems to me and my co-workers that the Flex compiler is broken when
it comes to local variable scoping within methods.

For example:

for (var i:int=0; i<count; i++)
{
   // do something
}

for (var i:int=0; i<count; i++)
{
   // do something else
}

This gives a compiler warning stating that 'i' is already defined. 
But in every other language that I have used, this is completely
valid.  Yes 'i' was defined above, but 'i' should only be scoped
within the 'for' loop and should be invalid outside of it.



Another example:

if (x)
{
   var myArray:Array = new Array();
   // do more stuff
}

myArray.push("some data");

This one compiles, when I believe that it shouldn't.  myArray should
only be defined within the 'if' statement.  If you don't go into the
'if' statement you have a problem here.


Does anyone understand why the Flex compiler allows this?  Is this
just a BUG with the compiler?

Anyway, this is just driving me a little crazy. ;)

Gary

Reply via email to