Bug 21050 – __traits(getOverloads) for templates returns incorrect symbol for the first overload
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-07-17T21:43:42Z
Last change time
2020-07-29T21:55:18Z
Keywords
pull
Assigned to
No Owner
Creator
Richard Manthorpe
Comments
Comment #0 by rmanth — 2020-07-17T21:43:42Z
struct S {
static void foo(T)(int i) {}
static void foo(T)(string s) {}
}
alias foo0 = __traits(getOverloads, S, "foo", true)[0];
alias bar0 = foo0!long; // Error: template `S.foo` matches more than one template declaration
alias foo1 = __traits(getOverloads, S, "foo", true)[1];
alias bar1 = foo1!int; // works fine
Trying to use the first overload is behaving exactly as if I were using S.foo directly.
Comment #1 by dlang-bot — 2020-07-19T14:02:28Z
@rmanthorpe created dlang/dmd pull request #11431 "Fix Issue 21050 - __traits(getOverloads) for templates returns incorr…" fixing this issue:
- Fix Issue 21050 - __traits(getOverloads) for templates returns incorrect symbol for the first overload
https://github.com/dlang/dmd/pull/11431
Comment #2 by dlang-bot — 2020-07-29T21:55:18Z
dlang/dmd pull request #11431 "Fix Issue 21050 - __traits(getOverloads) for templates returns incorr…" was merged into master:
- 9194d3aa930140cbd24829d4fb860e615b581c36 by Richard Manthorpe:
Fix Issue 21050 - __traits(getOverloads) for templates returns incorrect symbol for the first overload
Template declarations are nodes in a linked list of overloads.
Returning a template declaration from __traits(getOverloads)
returned the tail of that list of overloads. Instead we must
take a copy of the template declaration and remove references
to overnext and overroot so that it is no longer part of the
overload set.
https://github.com/dlang/dmd/pull/11431