On Fri, 15 Aug 2014 18:37:51 +0000, artemav wrote: > I'm getting an error when trying to compile (DMD64 D Compiler v2.066) > this: > > struct node(T) { > T data; node!T next; > }; > > void main() { > node!int n; > } > > output: > test.d(3): Error: struct test.node!int.node cannot have field next with > same struct type test.d(9): Error: template instance test.node!int error > instantiating ... > > It is so simple code that the error "... cannot have field next with > same struct type" looks funny and sad at the same time. Is it a bug or > are there some constraints why it cannot be compiled?
You want `node!(T)* next`. Structs are POD types, not reference types, so the node struct would have a infinite regression.