www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15777] New: Premature expansion of overload set in tuples


          Issue ID: 15777
           Summary: Premature expansion of overload set in tuples
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: thecybershadow gmail.com

/////////////////////// a.d //////////////////////
void fun() {}
/////////////////////// b.d //////////////////////
void fun() {}
///////////////////// test.d /////////////////////
alias AliasSeq(X...) = X;

template funA()
    import a;
    alias funA = fun;

template funB()
    import b;
    alias funB = fun;

template funAB()
    import a;
    import b;
    alias funAB = fun;

void test(alias tpl)()
    alias seq = AliasSeq!(tpl!());
    foreach (i, n; seq)
        pragma(msg, __traits(identifier, seq[i]));

void main()

The AliasSeq iteration works when seq is a single function, but when it's an
overload set, you get an error:

test.d(25): Error: variable test.test!(funAB).test.n variables cannot be of
type void
test.d(25): Error: b.fun at b.d(1) conflicts with a.fun at a.d(1)
test.d(25): Error: expression fun() is void and has no value
test.d(33): Error: template instance test.test!(funAB) error instantiating

Mar 07 2016