[Issue 14989] New: Overload merge sometimes doesn't work

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Aug 31 23:27:30 PDT 2015


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

          Issue ID: 14989
           Summary: Overload merge sometimes doesn't work
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com

I found this bug during maintenance AliasDeclaration::semantic() and
overloadInsert() functions.

Test code:

template Foo(T) if (is(T == int))    { enum Foo = 1; }
template Bar(T) if (is(T == double)) { enum Bar = 2; }
template Baz(T) if (is(T == string)) { enum Baz = 3; }

alias X = Foo;
alias X = Bar;
// X is an alias to is OverDeclaration
alias A = X;
// first, A->aliassym == X
static if (true)
{
    alias A = Baz;
    // A->aliassym = new OverDeclaration('A')
    // then, A->aliassym->overloadInsert(Baz)
}

template Mixa() { alias M = Foo; }
template Mixb() { alias M = Bar; }
mixin Mixa;
mixin Mixb;
alias Y = M;
// Y is an alias to OverloadSet
alias B = Y;
// first, B->aliassym == Y
static if (true)
{
    alias B = Baz;
    // (B->aliassym = new OverloadSet('B')
    // then, B->aliassym->overloadInsert(Baz)
}

void test()
{
    static assert(A!int    == 1);
    static assert(A!double == 2);
    static assert(A!string == 3);   // line 36

    static assert(B!int    == 1);
    static assert(B!double == 2);
    static assert(B!string == 3);   // line 40
}

Output:

test.d(36): Error: overload alias test.Foo does not match any template
declaration
test.d(40): Error: template instance test.B!string does not match template
overload set Bar

--


More information about the Digitalmars-d-bugs mailing list