www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9024] New: Inferring function argument types from other template parameters

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

           Summary: Inferring function argument types from other template
                    parameters
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: joseph.wakeling webdrake.net



2012-11-14 05:43:25 PST ---
The attached code most likely ought to be valid according to the spec at
http://dlang.org/template.html (point 2 under "Argument Deduction" states: "If
the type specialization is dependent on a type parameter, the type of that
parameter is set to be the corresponding part of the type argument"):

struct Foo(_T)
{
      alias _T T;
}

void func(T)(T foo, T.T x)
{
}

void main()
{
      Foo!int foo;
      func(foo, 3);
}

However, it fails to compile with an error

infer.d(13): Error: undefined identifier T.T
infer.d(13): Error: template infer.func does not match any function template
declaration
infer.d(13): Error: template infer.func(T) cannot deduce template function from
argument types !()(Foo!(int),int)

See discussion thread here:
http://forum.dlang.org/post/mailman.1810.1352724147.5162.digitalmars-d-learn puremagic.com
http://forum.dlang.org/post/mailman.1812.1352726032.5162.digitalmars-d-learn puremagic.com
http://forum.dlang.org/post/k7u134$1t35$1 digitalmars.com

... and also the following bug report where the issue is discussed:
http://d.puremagic.com/issues/show_bug.cgi?id=9004

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 14 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9024




2012-11-14 05:44:26 PST ---
Created an attachment (id=1161)
Minimal source code with example of the issue

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 14 2012