D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3576 - Can't overload explicitly instantiated template functions
Summary: Can't overload explicitly instantiated template functions
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-12-05 06:46 UTC by David Simcha
Modified: 2015-06-09 05:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2009-12-05 06:46:46 UTC
Broken in 2.037, works in 2.036:

void foo(T)(T arg) {}
void foo(T)(T arg, uint bar) {}

void main() {
    foo(1);          // works
    foo(1, 2);       // works
    foo!(uint)(1);   // Error: template instance foo!(uint) matches
                     // more than one template declaration, foo(T) and foo(T)

}
Comment 1 Walter Bright 2009-12-06 03:08:42 UTC
I know there was this change, but before it was a bit erratic what it did. I'll argue that the compiler is correctly saying it's an error.

Code can decide to do template function type inference, or overloading, but not both at the same time. By not specifying enough in the specialization, then inference rules are applied.

Trying to do both inference and overloading results in a complicated morass. Better to leave it an error.