[Issue 21058] New: __traits(getOverloads) forgets with with third argument or if first overload is a template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 19 16:17:48 UTC 2020


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

          Issue ID: 21058
           Summary: __traits(getOverloads) forgets with with third
                    argument or if first overload is a template
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: rmanth at gmail.com

struct A {
    int foo(string s) { return 0; }
}

static assert(__traits(getOverloads, A.init, "foo")[0]("hi") == 0); // works
static assert(__traits(getOverloads, A.init, "foo", true)[0]("hi") == 0); //
Error: need this for foo of type int(string s)

struct B {
    int foo()(int i) { return 1; }
    int foo(string s) { return 0; }
}

static assert(__traits(getOverloads, B.init, "foo")[0]("hi") == 0); // Error:
need this for foo of type int(string s)
static assert(__traits(getOverloads, B.init, "foo", true)[0]("hi") == 0); //
Error: need this for foo of type int(string s)
static assert(__traits(getOverloads, B.init, "foo", true)[1](7) == 1); //
Error: need this for foo of type pure nothrow @nogc @safe int(int i)

struct C {
    static int foo()(int i) { return 1; }
    int foo(string s) { return 0; }
}

static assert(__traits(getOverloads, C.init, "foo")[0]("hi") == 0); // Error:
need this for foo of type int(string s)
static assert(__traits(getOverloads, C.init, "foo", true)[0]("hi") == 0); //
Error: need this for foo of type int(string s)
static assert(__traits(getOverloads, C, "foo", true)[1](7) == 1); // works

--


More information about the Digitalmars-d-bugs mailing list