Thread overview
[Issue 1578] Allow AA literals to initialize static variables
Apr 11, 2015
yebblies
Apr 08, 2016
Edwin van Leeuwen
Oct 06, 2016
Xiao Di Guan
May 20, 2018
Ethan Watson
May 22, 2018
Dmitry Olshansky
Apr 12, 2021
mw
Apr 12, 2021
Ethan Watson
Dec 17, 2022
Iain Buclaw
April 11, 2015
https://issues.dlang.org/show_bug.cgi?id=1578

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johann.macdonagh@gmail.com

--- Comment #3 from yebblies <yebblies@gmail.com> ---
*** Issue 6238 has been marked as a duplicate of this issue. ***

--
April 08, 2016
https://issues.dlang.org/show_bug.cgi?id=1578

Edwin van Leeuwen <edder@tkwsping.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |edder@tkwsping.nl

--
October 06, 2016
https://issues.dlang.org/show_bug.cgi?id=1578

Xiao Di Guan <xdg@puxlit.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xdg@puxlit.net

--
May 20, 2018
https://issues.dlang.org/show_bug.cgi?id=1578

Ethan Watson <gooberman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gooberman@gmail.com

--- Comment #4 from Ethan Watson <gooberman@gmail.com> ---
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.

--
May 22, 2018
https://issues.dlang.org/show_bug.cgi?id=1578

Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc

--- Comment #5 from Dmitry Olshansky <dmitry.olsh@gmail.com> ---
*** Issue 5279 has been marked as a duplicate of this issue. ***

--
April 12, 2021
https://issues.dlang.org/show_bug.cgi?id=1578

mw <mingwu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mingwu@gmail.com

--- Comment #6 from mw <mingwu@gmail.com> ---
(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?

--
April 12, 2021
https://issues.dlang.org/show_bug.cgi?id=1578

--- Comment #7 from Ethan Watson <gooberman@gmail.com> ---
(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.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=1578

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--
October 29, 2023
https://issues.dlang.org/show_bug.cgi?id=1578

Steven Schveighoffer <schveiguy@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@gmail.com

--- Comment #8 from Steven Schveighoffer <schveiguy@gmail.com> ---
This will be fixed in 2.106, we must have missed this one when merging the fix.

https://github.com/dlang/dmd/pull/15468

--
October 29, 2023
https://issues.dlang.org/show_bug.cgi?id=1578

Steven Schveighoffer <schveiguy@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--