D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21050 - __traits(getOverloads) for templates returns incorrect symbol for the first overload
Summary: __traits(getOverloads) for templates returns incorrect symbol for the first o...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-07-17 21:43 UTC by Richard Manthorpe
Modified: 2020-07-29 21:55 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Richard Manthorpe 2020-07-17 21:43:42 UTC
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 Dlang Bot 2020-07-19 14:02:28 UTC
@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 Dlang Bot 2020-07-29 21:55:18 UTC
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