May be duplicate of http://d.puremagic.com/issues/show_bug.cgi?id=1253
Marking it critical as the only workaround I've found is dupping the array, which is not acceptable.
enum int[] a = [1 : 1];
void main()
{
auto e = a[0];
}
----
Error: array initializers as expressions are not allowed (x4)
Comment #1 by dfj1esp02 — 2008-09-30T04:04:29Z
workaround
invariant int[2] a = [1:1];
Comment #2 by samukha — 2008-10-01T07:34:00Z
works, thanks
Comment #3 by bugzilla — 2008-10-02T04:14:06Z
The error message is correct, and so is the workaround. Not a bug, though the array initializer syntax should be improved.
Comment #4 by dfj1esp02 — 2008-10-02T09:59:26Z
I've turned bug 1253 into tracker of struct/array initializers syntax issues. Or should we open a tracker explicitly?
Comment #5 by samukha — 2008-10-03T03:14:12Z
> Not a bug, though the
> array initializer syntax should be improved.
May I ask what's wrong with the syntax?
Also, since I can't remember when the compiler has been issuing duplicate error messages, which is a big stress factor :)