www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Array of closures assign

This D2 program compiles with no errors:

void delegate()[1] foo;
void main() {
    int n;
    foo[0] = { n++; };
}


But this one:

void delegate()[1] foo;
void main() {
    int n;
    foo[] = [{ n++; }];
}



test.d(4): Error: cannot implicitly convert expression ([delegate void()

{

n++;

}

]) of type void delegate()[] to const(void delegate()[])

Is this a front-end bug?

Bye,
bearophile
Dec 23 2010