Comment #0 by joseph.wakeling — 2012-11-14T05:43:25Z
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/[email protected]http://forum.dlang.org/post/[email protected]http://forum.dlang.org/post/[email protected]
... and also the following bug report where the issue is discussed:
http://d.puremagic.com/issues/show_bug.cgi?id=9004
Comment #1 by joseph.wakeling — 2012-11-14T05:44:26Z
Created attachment 1161
Minimal source code with example of the issue
Comment #2 by nick — 2023-02-28T18:31:08Z
Different error now:
tempspecinner.d(13): Error: none of the overloads of template `tempspecinner.func` are callable using argument types `!()(Foo!int, int)`
tempspecinner.d(6): Candidate is: `func(T)(T foo, T.T x)`
Comment #3 by robert.schadek — 2024-12-13T18:02:49Z