[Issue 18947] No way to get list of overloads from template mixins

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 13 07:45:19 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=18947

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Your solution requires me to change the type to get information that is already
available to the compiler elsewhere.

To top it off, the behavior is inconsistent:

mixin template foo(T) {
    static int fun(T) { return 0; }
}

struct S1 {
    mixin foo!int;
}

unittest {
    alias a = __traits(getMember, S1, "fun");
    a(1); // Works fine
    // Can get overloads when there's only one:
    static assert(__traits(getOverloads, S1, "fun").length == 1);
}

struct S2 {
    mixin foo!int;
    mixin foo!string;
}

unittest {
    __traits(getMember, S2, "fun")(2);  // Works fine
    __traits(getMember, S2, "fun")(""); // Works fine
    alias a = __traits(getMember, S2, "fun");
    a(2);  // Error: function expected before (), not void of type void
    a(""); // Error: function expected before (), not void of type void
}

struct S3 {
    static int fun(int) { return 0; }
    static int fun(string) { return 0; }
}

unittest {
    alias a = __traits(getMember, S3, "fun");
    a(3);  // Works fine
    a(""); // Works fine
}

--


More information about the Digitalmars-d-bugs mailing list