More bugs...
Timon Gehr
timon.gehr at gmx.ch
Sat Apr 28 02:40:48 PDT 2012
On 04/28/2012 09:46 AM, Max Samukha wrote:
> On Saturday, 28 April 2012 at 06:03:54 UTC, Mehrdad wrote:
>>> You expected that to work?
>>
>> Uhm, why not?
>>
>> template<class T>
>> struct F
>> {
>> F<F<T> > f() { return F<F<T> >(); }
>> };
>>
>> int main()
>> {
>> F<int>().f().f().f().f().f(); // etc.
>> return 0;
>> }
>>
>
> dmd is not smart enough
DMD behaves according to the language specification here.
> to avoid recursion by treating f as a
> templated function. I am not sure whether it should,
Maybe, but that would be a strange special case.
> but the following should certainly work:
>
> struct F(T)
> {
> auto f()() { return F!(F!T)(); }
> }
>
> void main()
> {
> F!int().f().f().f();
> }
>
> Error: struct a.F(T) recursive template expansion for template
> argument - why?
>
The checking for infinite recursion seems to be too conservative here.
You could open a bug report.
More information about the Digitalmars-d
mailing list