Troublemaker dmd 2.061 - Templates?

David d at dav1d.de
Sat Jan 5 08:52:10 PST 2013


mixin template get_packets_mixin(alias Module) {
    template get_packets() {
        alias NoDuplicates!(get_packets_impl!(__traits(allMembers,
Module))) get_packets;
    }

    private template get_packets_impl(T...) {
        static if(T.length == 0) {
            alias TypeTuple!() get_packets_impl;
        } else static if(__traits(compiles, mixin(T[0]).id)) {
            pragma(msg, T);
            alias TypeTuple!(PacketTuple!(mixin(T[0]), mixin(T[0]).id),
get_packets_impl!(T[1..$])) get_packets_impl;
        } else {
            alias TypeTuple!(get_packets_impl!(T[1..$])) get_packets_impl;
        }
    }

    template PacketTuple(T, ubyte b) {
        alias T cls;
        alias b id;
    }

    pragma(msg, get_packets_impl!(__traits(allMembers, Module)));
    //pragma(msg, get_packets!());
}


This code worked fine from dmd 2.058 to 2.060 now it fails, haha you
might think, gives you an error! no, it failed silently, and the pragma
prints me "_error_", what a glorious message!, can anyone see if there
is something wrong with this code? I don't see an error. Bug must be
somewhere in get_packets_impl.

http://dpaste.dzfl.pl/d703d10e (code from above)


More information about the Digitalmars-d-learn mailing list