On Thu, Dec 22, 2011 at 12:04 AM, pompei2 <[email protected]> wrote: >> int delegate(int delegate(ref int)) doIter() const >> { >> 74 return (int delegate(ref int) dg) >> { >> cast(typeof(this))(this).doIter() >> 77 ( >> 78 (ref int i) >> >> { >> int copy = i; dg(copy); >> } >> ); >> } >> } > > > I see what you are doing there. Unfortunately, the innermost delegate (the > one doing the copy trick) somehow got @system attribute, which leads to the > following compile errors (I added line numbers and reordered your code in > the citation above): > > constiter.d(78): Error: cannot implicitly convert expression (__dgliteral2) > of type void delegate(ref int i) @system to int delegate(ref int) > constiter.d(77): Error: cast has no effect in expression > (cast(const(Container))this.doIter()((__error))) > constiter.d(74): Error: cannot implicitly convert expression (__dgliteral1) > of type void delegate(int delegate(ref int) dg) @system to int delegate(int > delegate(ref int)) > > Where does this @system come from? How do I get rid of it?
Actually, it looks like your issue is here: constiter.d(78): Error: cannot implicitly convert expression (__dgliteral2) of type *void* delegate(ref int i) @system to int delegate(ref int) void delegate(ref int) != int delegate(ref int)
