Delegate type inferred as pure

Kenji Hara k.hara.pg at gmail.com
Mon Jan 28 04:50:27 PST 2013


On Monday, 28 January 2013 at 03:16:24 UTC, cal wrote:
> This fails:
>
> void main() {
>     int z;
>     typeof((int a){return z;}) dg;
>     dg = (int a) {return z;};
> }
>
> Error: cannot implicitly convert expression (__lambda2) of type 
> int delegate(int a) nothrow @safe to int delegate(int a) pure 
> nothrow @safe
>
> But I can't make the delegate pure:
> dg = (int a) pure {return z;};
> because it references z.
>
> Is the 'typeof((int a){return z;})' getting it wrong here?

Filed:
http://d.puremagic.com/issues/show_bug.cgi?id=9415


More information about the Digitalmars-d-learn mailing list