[haXe] Bug in cast() implementation when compiling for Flash 9?

Daniel Cassidy lezekdan at gmail.com
Mon Nov 6 14:33:29 CET 2006


Hi list,

I have been trying to track down some slightly inexplicable bugs when
compiling for Flash 9, and it seems that the culprit is haXe
generating code for cast() that can only be used in fairly restrictive
contexts:

class A {
	public function new () {
	}
}

class B extends A {
	public function new () {
		super();
	}
}

class Test {
	public static function main () {
		var arr1:Array<A> = [ cast(new B(), A) ];
		// OK

		var arr2:Array<A> = [ cast(new B(), A), new B() ];
		// OK

		var arr3:Array<A> = [ cast(new B(), A), cast(new B(), A) ];
		// characters 48-68 : Cannot compile try/catch as a right-side
expression in Flash9
		// (chars 48-68 are the first "cast(new B(), A)")

		arr1.push(new Bar());
		// OK

		arr1.push(cast(new Bar(), Foo));
		// same error as above
	}
}


All of the above code compiles fine for Neko and Flash 8.

Is this behaviour intentional? Can the error message be made more
informative if it is? :)

Thanks,
Dan.



More information about the Haxe mailing list