www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1641] New: Template function arg deduction gets confused when used with the inner name trick

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

           Summary: Template function arg deduction gets confused when used
                    with the inner name trick
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


The use case is simple:


template foo(T)
{
    void foo(U)(U a, T b, T c)
    {
    }
}

void main()
{
    int x;
    foo!(uint)(x, 0, 1);
}

The template engine should properly bind 0 and 1 to type uint, but it fails to
do so. As a result, the entire program does not compile although it should.


-- 
Nov 05 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1641


shro8822 vandals.uidaho.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shro8822 vandals.uidaho.edu




------- Comment #1 from shro8822 vandals.uidaho.edu  2007-11-05 16:21 -------
If you convert the call to:

foo!(uint)(x, 0u, 1u);
or
foo!(int)(x, 0, 1);

it works. This might indicate that type conversion is not working correctly
here. Either way it gives a work around to any one who just need to get
something done.


-- 
Nov 05 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1641


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |rejects-valid
            Summary|Template function arg       |Template function arg
                   |deduction gets confused when|deduction gets confused when
                   |used with the inner name    |used with implicit
                   |trick                       |conversions




------- Comment #2 from smjg iname.com  2007-11-11 10:53 -------
No nested template is required - this is sufficient to show the problem (DMD
1.023 and 2.007, Windows):
----------
void foo(U)(U a, uint b, uint c) {
}

void main() {
    int x;
    foo(x, 0, 1);
}
----------
bz1641a.d(6): template bz1641a.foo(U) does not match any template declaration
bz1641a.d(6): template bz1641a.foo(U) cannot deduce template function from
argument types (int,int,int)
----------

So the problem is that, when trying to perform IFTI, it doesn't look for
implicit conversions.


-- 
Nov 11 2007