Comment #0 by bearophile_hugs — 2010-10-31T14:20:21Z
This is borderline between enhancement and rejects-valid bug report.
DMD 2.050 doesn't support this code:
int[1][1] foo() {
int[1][1] a;
return a;
}
enum int[1][1] m1 = foo();
immutable int[1][1] m2 = foo();
void main() {}
Errors generated:
test.d(2): Error: Slice operation a[] = 0 cannot be evaluated at compile time
test.d(5): Error: cannot evaluate foo() at compile time
This code is very useful to initialize an enum/immutable global matrix.
Comment #1 by michal.minich — 2010-10-31T14:49:37Z
I would like to point out that this code works:
int[1] foo2() {
int[1] a;
return a;
}
enum int[1] m3 = foo2();
immutable int[1] m4 = foo2();
void main() {}
Comment #2 by bearophile_hugs — 2010-10-31T16:31:43Z