The spec grammar allows EnumBody to be just a semicolon, however a little further down it also says that enums must have at least one member. This compiles however: enum a;
Either this is a contradiction in the spec, or we need clarification of what ';' as an EnumBody means.
This would be fixed by changing the EnumBody rule to EnumBody: EnumMember ; { EnumMembers }
So the meaning of that code changes from declaring an enum type with no members to declaring a manifest constant with value 0.
(In reply to comment #3) > So the meaning of that code changes from declaring an enum type with no members > to declaring a manifest constant with value 0. That seems more reasonable to me. However, if you specify a type as well, DMD rejects it: enum long a; enum1.d(1): Error: variable enum1.a manifest constants must have initializers So at the moment it is inconsistent.
I think the semicolon is intended to handle manifest constants. However, it doesn't look quite right. If the grammar is rewritten as follows: EnumDeclaration: enum EnumBody enum EnumTag EnumBody enum : EnumBaseType EnumBody enum EnumTag : EnumBaseType EnumBody enum EnumMember ; EnumBody: { EnumMembers } Then manifest constants will be handled by the grammar, although the compiler enforces that they need an initializer.
Commit pushed to https://github.com/D-Programming-Language/d-programming-language.org https://github.com/D-Programming-Language/d-programming-language.org/commit/31be563dc0bc4afaaf84c24deb527d60c3ec2e83 fix Issue 2351 - enum with no members allowed