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