Bug 14989 – Overload merge sometimes doesn't work

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-09-01T06:27:00Z
Last change time
2016-02-14T11:03:48Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2015-09-01T06:27:30Z
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
Comment #1 by k.hara.pg — 2015-09-01T06:40:26Z
Comment #2 by github-bugzilla — 2016-02-14T11:03:48Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2f5c855c2d1dcbdf6a5ee17125ab640af7fdb23a fix Issue 14989 - Overload merge sometimes doesn't work https://github.com/D-Programming-Language/dmd/commit/e0eb338e8e4ba03b8a8b546b0eb5709fbf0fe833 Merge pull request #5009 from 9rnsr/fix14989 Issue 14989 - Overload merge sometimes doesn't work