Closed Sword352 closed 5 days ago
Hej,
A workaround could be something like that : https://try.haxe.org/#28E4147C
@:build(Macro.build("hi", "hello", 0))
class Test {
static function main() {
trace("Haxe is great!");
}
}
import haxe.macro.Expr;
using haxe.macro.ExprTools;
class Macro {
#if macro
public static function build(...args:Expr):Array<Field> {
var a = args.toArray().map( e->e.getValue() );
trace( a );
return haxe.macro.Context.getBuildFields();
}
#end
}
Turns out this is normal behaviour
For some reason it's impossible to pass a mixed array when doing a macro call with the
@:build
metadata.Example:
Output:
What I also find weird is the fact that the value's type seems to be resolved. I rather have an anonymous structure on my end, with a dynamic
value
field. When hovering the anon structure in my IDE,value
is displayed with a type ofInt
when it's value is equal to 0, for example. On plain context it would be displayed with theDynamic
type no matter what.