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)'
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)'
This issue is a show stopper for the Arc v.2 release, unless we find a workaround of some sort.
Created attachment 148 [details] patch to DMD 0.175
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.
Fixed DMD 1.018 and DMD 2.002
Added to DStress as http://dstress.kuehne.cn/run/t/template_64_A.d http://dstress.kuehne.cn/run/t/template_64_B.d http://dstress.kuehne.cn/run/t/template_64_C.d
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル