Bug 12111 – Cannot pull a function template into an overload set

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-08T12:46:24Z
Last change time
2018-02-25T12:24:00Z
Assigned to
No Owner
Creator
Nick Sabalausky

Comments

Comment #0 by bus_dbugzilla — 2014-02-08T12:46:24Z
Works with regular functions, but not function templates: ------------------------------ module a; import b; alias foo = b.foo; void foo(T)(T t) if(is(T==char)) {} void main() { foo(1); } ------------------------------ module b; void foo(T)(T t) if(is(T==int)) {} ------------------------------ Error: template a.foo(T)(T t) if (is(T == char)) conflicts with alias a.foo at a.d(4) FWIW, The problem does not appear to be related to the "if(...)" constraints, because using these foo's has the same problem: void foo(T)(int[T] t) {} void foo(T)(T[] t) {}
Comment #1 by bus_dbugzilla — 2014-02-08T13:22:53Z
Workaround: ------------------------------ module a; import b; alias foo = b.foo; void foo(T)(T t) if(is(T==char)) {} void foo(T)(T t) if(is(T==int)) { b.foo(t); } // Workaround for #12111 void main() { foo(1); } ------------------------------ module b; void foo(T)(T t) if(is(T==int)) {} ------------------------------
Comment #2 by bus_dbugzilla — 2015-06-12T03:57:41Z
Better workaround, just change: alias foo = b.foo; to alias foo() = b.foo; I'm no longer certain whether or not this is actually a bug.
Comment #3 by ag0aep6g — 2018-02-25T12:24:00Z
Works for me with 2.078.3.