Passing functions as args into @:build macros

There seems to be a bunch of weird restrictions regarding passing functions as arguments into build macros, this works fine:

@:build(Macro.test((s) -> true))
class Test1 {}

I can’t reference class functions:

@:build(Macro.test(TestFilter.filter))// EvalContext.RunTimeException(_, 0, _)
class Test2 {}

class TestFilter {
	static public function filter(path:String):Bool
		return true;

I can’t call trace

    (s) -> {
        trace(s);// Unknown identifier: `trace
        return s != "bar";
class Test3 {}

can’t even reference StringTools

@:build(Macro.test((s) -> StringTools.contains(s, "bar"))) // Uncaught exception Cannot call null
class Test4 {}

Is there any way around this?

For one reason or another the forum decided to send me a link to this post. Well, as long as I’m here, I might as well leave a note for posterity.

Geo submitted this as an issue, and Simn confirmed that it’s fixed in the development version.

1 Like