Thread overview
[Issue 22052] Struct array initializer for enum member fails to compile
Jun 20, 2021
Max Samukha
Jun 21, 2021
Basile-z
Jun 21, 2021
Max Samukha
Jun 21, 2021
Basile-z
Dec 17, 2022
Iain Buclaw
June 20, 2021
https://issues.dlang.org/show_bug.cgi?id=22052

Max Samukha <maxsamukha@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|Windows                     |All

--
June 21, 2021
https://issues.dlang.org/show_bug.cgi?id=22052

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

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

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
This is not supposed to work actually, so changed the importance to enhancement.

By [1] the construct exepected here is

```ebnf
Type Identifier "=" AssignExpression
```

while struct initializer is part of another rule, i.e Initializer ([2])

The enhancement would be to have

```ebnf
Type Identifier "=" Initializer
```

[1] https://dlang.org/spec/enum.html#AnonymousEnumMember [2] https://dlang.org/spec/declaration.html#Initializer

--
June 21, 2021
https://issues.dlang.org/show_bug.cgi?id=22052

--- Comment #2 from Max Samukha <maxsamukha@gmail.com> ---
(In reply to Basile-z from comment #1)
> This is not supposed to work actually, so changed the importance to enhancement.
> 

I don't agree that is an enhancement.

https://dlang.org/spec/enum.html#manifest_constants: "If there is only one member of an anonymous enum, the { } can be omitted. Gramatically speaking, this is an AutoDeclaration."

That is, the following two are supposed to be consistent, but only the former compiles:

enum Dependency[] dependencies = [
        { name: "foo" }
    ];

enum {
    Dependency[] dependencies = [
        { name: "foo" }
    ]
}


Why are enum members initialized with AssignExpression instead of Initializer? If there is no reason other than historical, it is a bug.

--
June 21, 2021
https://issues.dlang.org/show_bug.cgi?id=22052

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |normal

--- Comment #3 from Basile-z <b2.temp@gmx.com> ---
yeah you're right, there's is a fog here. I missed the point when following strictly the grammar and ignoring the desciption.

restored to a normal bug ;)

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--
December 13
https://issues.dlang.org/show_bug.cgi?id=22052

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18042

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--