Bug 2626 – template function not working against template struct instantiated with default arguments

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-01-27T17:01:00Z
Last change time
2015-06-09T05:15:11Z
Assigned to
bugzilla
Creator
andrei

Comments

Comment #0 by andrei — 2009-01-27T17:01:00Z
The following code doesn't compile: struct S(T, int x = 1){} S!(T, x) fun(T, int x)(T a, S!(T, x) b) {return b;} void main() { S!(int) s; s = fun(2, s); } Error message: ./test.d(nn): template test.fun(T,int x) does not match any function template declaration ./test.d(nn): template test.fun(T,int x) cannot deduce template function from argument types !()(int,S!(int)) ./test.d(nn): Error: cannot implicitly convert expression ((fun(T,int x))(2,s))of type int to S!(int) Changing the definition of s to: S!(int, 4) s; makes the code work, so I presume it's a simple bug.
Comment #1 by bugzilla — 2009-02-28T04:11:21Z
Here's a simpler version, but fixing it isn't: struct S(int x = 1){} void fun()(S!(1) b) { } void main() { S!() s; fun(s); }
Comment #2 by bugzilla — 2009-04-01T13:53:09Z
Fixed DMD 2.027