[Issue 22052] Struct array initializer for enum member fails to compile

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 21 07:51:52 UTC 2021


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

--- Comment #2 from Max Samukha <maxsamukha at 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.

--


More information about the Digitalmars-d-bugs mailing list