Summary: template function not working against template struct
                    instantiated with default arguments
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

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,int x) does not match any function template
./test.d(nn): template,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.


Reply via email to