Bug 8373 – IFTI fails on overloading of function vs non function template

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-10T13:39:00Z
Last change time
2014-04-19T18:09:54Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2012-07-10T13:39:52Z
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.
Comment #1 by issues.dlang — 2012-07-10T13:49:31Z
This looks very similar to bug# 8316, but I'm not sure if it's the same thing.
Comment #2 by timon.gehr — 2012-07-10T13:55:43Z
(In reply to comment #1) > This looks very similar to bug# 8316, but I'm not sure if it's the same thing. Thank you for looking that up, but it is a different issue. The underlying problem in bug# 8316 is that the compiler does not interpret the statement as a function call, and therefore the instantiation is ambiguous. In this case the compiler errors out on the matching template with the error message that would be adequate if only the non-matching template was present.
Comment #3 by k.hara.pg — 2014-04-16T05:09:02Z
(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)
Comment #4 by github-bugzilla — 2014-04-19T18:09:54Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c542416605ea13c5601a586c21e58a4332f7819c fix Issue 8373 - IFTI fails on overloading of function vs non function template https://github.com/D-Programming-Language/dmd/commit/c87714289d25bfca41cb39bf5c0a6f12c4773119 Merge pull request #3459 from 9rnsr/fix8373 Issue 8373 - IFTI fails on overloading of function vs non function template