[Issue 8373] IFTI fails on overloading of function vs non function template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 15 22:09:02 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=8373

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, pull

--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to timon.gehr from comment #0)
> DMD 2.059:
> auto fun(T...)(T args){return 1;}
> template fun(a...){auto fun(T...)(T args){return 2;}}
> static assert(fun(0)==1); // error
> 
> The call matches only the first declaration, therefore the overload
> resolution
> should succeed.

https://github.com/D-Programming-Language/dmd/pull/3459

This is order-dependent bug. If you swap the positions of two 'fun's,

template fun(a...){auto fun(T...)(T args){return 2;}}
auto fun(T...)(T args){return 1;}
static assert(fun(0)==1); // error

It will cause correct error for ambiguity.

test.d(3): Error: test.fun called with argument types (int) matches both:
test.d(1):     test.fun!().fun!(int).fun(int)
and:
test.d(2):     test.fun!(int).fun(int)

--


More information about the Digitalmars-d-bugs mailing list