Bug 3576 – Can't overload explicitly instantiated template functions

Status
RESOLVED
Resolution
WONTFIX
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-12-05T06:46:00Z
Last change time
2015-06-09T05:13:48Z
Keywords
rejects-valid
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-12-05T06:46:46Z
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 by bugzilla — 2009-12-06T03:08:42Z
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.