Macro enigma


Can anyone explain me what happens here please ? Try Haxe !

If I don’t use the haxe.macro.Context.typeExpr() all works fine.
If I add “else” statement at the end (the commented part), all works fine, if not it throws me Void should be String
Also, if in the catch block I just trace the error (without throwing a fatalError), all works fine.

Many thanks for anyone who give me the reason why does this happen please.

Ok, thanks to @haxiomic I think I’ve understood :

I ask compiler to type a buffer of expressions. All is working fine until the if/else if statement without final else statement because in Haxe the type of a block is its last expression’s type.
When compiler arrives to the if/else if statement, it’s its last expression (for now) and without any final else statement it falls into a dilemma between String and Void…

Sorry for the disturbing !

1 Like