Local variables have backwards scope in AIR 23
Hi!
Upon updating to latest AIR to rebuild my iOS app with iOS 10 support, I have run into an incompatibility, and narrowed it down to a change in scope behaviour of locally declared variables.
Formerly, a locally declared variable was only accessible starting from wherever it was declared and retaining the scope until the end of a function. Currently, a locally defined variable is scoped backwards and can be accessed from the beginning of the function, even before its declaration, even if it is declared in a deeper scope. This poses issues when local variables are named exactly the same as class properties.
Below is a reproduction snipped.
package {
import flash.display.Sprite;
public class Main extends Sprite {
public var a:Number = 4;
public function Main() {
trace(a); // NaN
if (true) { var a:Number = 0; }
trace(a); // 0
}
}
}
I would like to inquire whether this is a bug, and undocumented language specification change, or undefined behaviour.
Cheers!
Sos
EDIT:
Apache Flex, and previous versions of Adobe AS3 compilers would trace 4 and 0, respectively, as expected.
