www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2626] New: template function not working against template struct instantiated with default arguments

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2626

           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
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


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.


-- 
Jan 27 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2626





------- Comment #1 from bugzilla digitalmars.com  2009-02-28 04:11 -------
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);
}


-- 
Feb 28 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2626


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2009-04-01 13:53 -------
Fixed DMD 2.027


-- 
Apr 01 2009