A template member function with nesting confuses the compiler. It is fine with the equivalent construct existing outside a class. It only breaks when you put it inside the class.
class Foo {
template myCast(T) {
T myCast(U)(U val) {
return cast(T) val;
}
}
}
void main() {
Foo foo = new Foo;
int i = foo.myCast!(int)(1.0);
}
-->
Error: function expected before (), not 'foo dotexp template myCast(U)'
Comment #1 by kamm-removethis — 2007-04-24T03:18:20Z
You can also easily trigger this IFTI problem with named template mixins:
template A()
{
static void foo(T)(T t) {}
}
struct Bar
{
mixin A!() a;
}
void main()
{
A!().foo(1); // works
Bar.a.foo!(int)(1); // works
Bar.a.foo(1); // error
}
Error: function expected before (), not 'Bar dotexp template foo(T)'
Comment #2 by clayasaurus — 2007-06-20T10:38:53Z
This issue is a show stopper for the Arc v.2 release, unless we find a workaround of some sort.
Comment #3 by oskar.linde — 2007-06-21T06:02:09Z
Created attachment 148
patch to DMD 0.175
Comment #4 by oskar.linde — 2007-06-21T06:03:05Z
Here is a patch to DMD 0.175 that fixes this issue (posted december 1st to the announce newsgroup). It is not really well tested, but illustrates that the required change is quite small.