benmerckx / genes

Generates split ES6 modules and Typescript definitions from Haxe modules.
44 stars 8 forks source link

Uncatchable haxe.macro.Context.typeof() when dealing with TExtend #14

Closed kevinresol closed 4 years ago

kevinresol commented 4 years ago

4.0.5

// Main.hx
class Main {
    static function main()
        Macro.run();
}

typedef Obj1 = {foo:Int}
typedef Obj2 = {foo:String}

// Macro.hx
import haxe.macro.Expr;
import haxe.macro.Context;

class Macro {
    public static macro function run() {
        try {
            var ct = TExtend([
                {pack: [], name: 'Main', params: [], sub: 'Obj1'},
                {pack: [], name: 'Main', params: [], sub: 'Obj2'},
            ], []);
            Context.typeof(macro {
                var v:$ct = null;
                v;
            });
        } catch(e:Dynamic) {
            trace(e);
        }

        return macro null;
    }
}

Fails with Cannot redefine field foo with different type and the error is uncatchable

kevinresol commented 4 years ago

This was meant for Haxe. Sorry for misposting.