The documentation for EnumMember states that it can consist of "type '=' assignExpression", but comments in the the compiler source code indicate that this should actually be "type Identifer '=' assignExpression".
Another issue is that the grammar does not disallow the "type Identifier '=' assignExpression" syntax if the enum has a name or base type specified, but DMD's parser does.
Comment #1 by andrej.mitrovich — 2014-04-22T22:25:53Z
(In reply to brian-schott from comment #0)
> The documentation for EnumMember states that it can consist of "type '='
> assignExpression", but comments in the the compiler source code indicate
> that this should actually be "type Identifer '=' assignExpression".
You mean this?:
-----
alias Base = int;
enum : Base
{
x = 1
}
-----
This is a supported feature.
> Another issue is that the grammar does not disallow the "type Identifier '='
> assignExpression" syntax if the enum has a name or base type specified, but
> DMD's parser does.
I'm not sure what exactly the parser disallows. Can you post an example?
Comment #2 by briancschott — 2014-04-22T23:12:23Z
The compiler accepts this even though it makes no sense:
enum
{
int = 5
}
The compiler rejects this though the grammar allows it:
enum A
{
int b = 5
}
Comment #3 by andrej.mitrovich — 2014-04-22T23:26:39Z
(In reply to brian-schott from comment #2)
> The compiler accepts this even though it makes no sense:
>
> enum
> {
> int = 5
> }
https://github.com/D-Programming-Language/dmd/pull/3487
A spec pull will have to be made for the second issue.
Comment #4 by github-bugzilla — 2014-04-24T20:43:19Z