www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21491] New: Can't enumerate overload set from mixin templates


          Issue ID: 21491
           Summary: Can't enumerate overload set from mixin templates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

If functions with the same name across several mixed-in mixin templates create
an overload set, it is invisible to getOverloads:

///////////////////////// test.d /////////////////////////
struct A
    void ov(int){}
    void ov(string){}

struct B
    mixin template M()
        void ov(int){}
        void ov(string){}
    mixin M;

struct C
    mixin template M(T)
        void ov(T){}
    mixin M!int;
    mixin M!string;

pragma(msg, __traits(getOverloads, A, q{ov})); // OK
pragma(msg, __traits(getOverloads, B, q{ov})); // OK
pragma(msg, __traits(getOverloads, C, q{ov})); // nothing?

This is despite that the functions otherwise act like an overload set, i.e.:

C c; c.ov(1); c.ov("2");

works as expected.

Dec 19 2020