Last active
August 29, 2015 13:59
-
-
Save SmilyOrg/10593151 to your computer and use it in GitHub Desktop.
Haxe compiler Array<FunctionArg> @:optional unintuitive typing?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
static function main() { | |
var args = [{ name: "abc", type: null }]; // FAILS | |
//var args = [{ name: "abc", type: null, opt: false, value: null }]; // WORKS | |
//var args:Array<FunctionArg> = [{ name: "abc", type: null }]; // WORKS | |
(args:Array<haxe.macro.Expr.FunctionArg>); | |
/* | |
Compiler throws the following error for the first option: | |
test/Test.hx:8: characters 3-7 : Array<{ type : Null<haxe.macro.ComplexType>, name : String }> should be Array<haxe.macro.FunctionArg> | |
test/Test.hx:8: characters 3-7 : Type parameters are invariant | |
test/Test.hx:8: characters 3-7 : { type : Null<haxe.macro.ComplexType>, name : String } should be haxe.macro.FunctionArg | |
test/Test.hx:8: characters 3-7 : { type : Null<haxe.macro.ComplexType>, name : String } should be { ?value : Null<haxe.macro.Expr>, type : Null<haxe.macro.ComplexType>, ?opt : Bool, name : String } | |
test/Test.hx:8: characters 3-7 : { type : Null<haxe.macro.ComplexType>, name : String } has no field opt | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment