haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Result of Context.getExpectedType() depends on prev Context.typeof() calls.

Open pecheny opened this issue 7 months ago • 0 comments

If macro function receives non primitive args, getExpectedType() returns null after Context.typeof() call. Reproduces on all the nightlies but works fine on 4.3.6.

class Macro {
    public static macro function create2<T>(extra:Array<Expr>) {
        trace( Context.getExpectedType()); //TType(Map,[TInst(String,[]),TAbstract(Int,[])])
        var valCt0 = Context.typeof(extra[0]);
        trace( Context.getExpectedType()); // null
        return macro null;
    }
}
class Test {
  static function main() {
            var avec2:Map<String, Int> = Macro.create2(new haxe.ds.Vector(1)); // arguments of primitive types does'n break results
  }
}

https://try.haxe.org/#70A7a3b4

pecheny avatar Apr 26 '25 14:04 pecheny