Delegate type inferred as pure

cal callumenator at gmail.com
Sun Jan 27 19:16:20 PST 2013


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?


More information about the Digitalmars-d-learn mailing list