D-Programming-Language/dmd — pull request #1197 by Poita (2012-10-20 09:55:36+00:00)
Title: Failed template match error now lists candidates.

In an attempt to gradually improve template errors, when a template usage fails to match a template declaration it will now list the candidates, so that the user can see all the overloads in one place. This makes it easier to figure out why the match failed.

Example:
```d
void foo(T)(T r) if (is(T : string)) {}
void foo(T)(T a, T b) {}
int x = foo(0);
```
gives
```d
foo.d(3): Error: template foo.foo does not match any function template declaration. Candidates are:
foo.d(1): foo.foo(T) if (is(T : string))
foo.d(2): foo.foo(T)
foo.d(1): Error: template foo.foo cannot deduce template function from argument types !()(int)
```
Notice that the location of each overload is shown, too.

If there are over 100 candidates, then it will only show 100 and then end with a line saying "... X more ...", just in case someone has generated some crazy number of overloads.

Next step from here is to offer better diagnostics as to why each instantiation failed.