Reduced test case:
static int sizemap[int]= [0:0, 1:1, 2:4, 3:8, 4:8, 4:16];
changed title from "const initializer rejected".
Comment #3 by yebblies — 2015-04-11T03:39:03Z
*** Issue 6238 has been marked as a duplicate of this issue. ***
Comment #4 by gooberman — 2018-05-20T19:35:59Z
Came here from issue 6238
10.5 years and this is still a problem. Encountered when trying to assign AA literal to a struct member.
See https://run.dlang.io/is/BDVjxP for another example.
Comment #5 by dmitry.olsh — 2018-05-22T09:08:59Z
*** Issue 5279 has been marked as a duplicate of this issue. ***
Comment #6 by mingwu — 2021-04-12T21:42:02Z
(In reply to Don from comment #2)
> Reduced test case:
>
> static int sizemap[int]= [0:0, 1:1, 2:4, 3:8, 4:8, 4:16];
>
> changed title from "const initializer rejected".
The work-around is:
enum int[int] sizemap= [0:0, 1:1, 2:4, 3:8, 4:8, 4:16];
BTW, this is a very old issue, if it's not intended to be fixed, can we add to the doc, and close it?
Comment #7 by gooberman — 2021-04-12T22:09:58Z
(In reply to mw from comment #6)
> The work-around is:
>
> enum int[int] sizemap= [0:0, 1:1, 2:4, 3:8, 4:8, 4:16];
That's not a workaround *at all*. That's defining a constant. My example from 2018 even illustrates exactly this, and that assigning the constant to a static variable does not work.