[Issue 19095] Static initiatization statements of an array appeared in different kind of scopes have inconsistent semantics

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 18 15:00:44 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19095

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

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

--- Comment #1 from Basile B. <b2.temp at 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.

--


More information about the Digitalmars-d-bugs mailing list