Thread overview
[Issue 19095] Static initiatization statements of an array appeared in different kind of scopes have inconsistent semantics
Jul 18, 2018
Basile B.
Jul 18, 2018
Basile B.
Jul 18, 2018
Basile B.
Jul 19, 2018
Hiroki Noda
Jul 19, 2018
Basile B.
Nov 18, 2019
Dlang Bot
Mar 21, 2020
Basile-z
May 15, 2020
Mathias LANG
May 15, 2020
Mathias LANG
Dec 17, 2022
Iain Buclaw
July 18, 2018
https://issues.dlang.org/show_bug.cgi?id=19095

Basile B. <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |b2.temp@gmx.com
         Resolution|---                         |INVALID

--- Comment #1 from Basile B. <b2.temp@gmx.com> ---
Not a bug as you say. And this is too different constructs, not related to static initialization (which means that the title of the report is not correct btw), see https://dlang.org/spec/declaration.html#NonVoidInitializer

ArrayInitializer

    int[2] ARR = [1];  // "[" -> left square so parse a "ArrayInitializer"

ExpInitializer

    int[2] ARR_2 = foo(); // "f" -> ident char so parse a "ExpInitializer"

ArrayInitializer is useful to make lookup tables, i.e you mostly want the default value but a particular value for a few cases. This cant be fixed, it's part of the language and it's used, notably, in the source code of the runtime for example. It would not be reasonable to force all entries to be initialized.

--
July 18, 2018
https://issues.dlang.org/show_bug.cgi?id=19095

--- Comment #2 from Basile B. <b2.temp@gmx.com> ---
(In reply to Basile B. from comment #1)
> Not a bug as you say. And this is too different constructs

Forgot to say but, the error you made is to think that the call to "foo()" is eluded, i.e simplified to its return.

--
July 18, 2018
https://issues.dlang.org/show_bug.cgi?id=19095

--- Comment #3 from Basile B. <b2.temp@gmx.com> ---
(In reply to Basile B. from comment #2)
> (In reply to Basile B. from comment #1)
> > Not a bug as you say. And this is too different constructs
> 
> Forgot to say but, the error you made is to think that the call to "foo()" is eluded, i.e simplified to its return.

In the foo() call you have an 'ArrayLiteral', which does not allow the freedom of of 'ArrayInitializer', for obvious reasons : when used in expressions the whole stuff is required, while in an initializer a special semantic can be applied since the type of the thing to stuff is (usually) known.

--
July 19, 2018
https://issues.dlang.org/show_bug.cgi?id=19095

--- Comment #4 from Hiroki Noda <kubo39@gmail.com> ---
Thank you for the explanations, yes, the title of the report is not correct. I am still not convinced that the global array initialization has been successful in this case.

(Attemptive PR : https://github.com/dlang/dmd/pull/8503)

--
July 19, 2018
https://issues.dlang.org/show_bug.cgi?id=19095

Basile B. <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---
           Severity|trivial                     |normal

--- Comment #5 from Basile B. <b2.temp@gmx.com> ---
Sorry if i've closed this a bit eagerly but actually i wanted to do the same something like 18 months ago and you'll see that in addition to your PR you'll have to fix druntime and Phobos which use this syntax, which means that the change is much less trivial that it appears at first glance. The final decision owns to the D team so you'll see what people think in the PR.

--
November 18, 2019
https://issues.dlang.org/show_bug.cgi?id=19095

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #10585 "Fix Issue 19095 - deprecate array length mismatch in global static arrays" fixing this issue:

- Fix Issue 19095 - deprecate array length mismatch in global static arrays

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

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=19095

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--
May 15, 2020
https://issues.dlang.org/show_bug.cgi?id=19095

Mathias LANG <pro.mathias.lang@gmail.com> changed:

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

--- Comment #7 from Mathias LANG <pro.mathias.lang@gmail.com> ---
*** Issue 10192 has been marked as a duplicate of this issue. ***

--
May 15, 2020
https://issues.dlang.org/show_bug.cgi?id=19095

--- Comment #8 from Mathias LANG <pro.mathias.lang@gmail.com> ---
Note that bearophile had a few more test cases and useful links: https://issues.dlang.org/show_bug.cgi?id=10192

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--