Bug 10285 – Enum grammar documentation is incorrect

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-06T14:28:00Z
Last change time
2015-01-18T09:27:00Z
Keywords
pull, spec
Assigned to
andrej.mitrovich
Creator
briancschott
Blocks
10233

Comments

Comment #0 by briancschott — 2013-06-06T14:28:06Z
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
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/610b68e795a67bd0cb4c362caa2905a6ddfcf1a7 Fix Issue 10285 - Enum member with a type but no identifier should not be allowed. https://github.com/D-Programming-Language/dmd/commit/90abd4c6cdfd2f2672c338c3eb491d177dcae937 Merge pull request #3487 from AndrejMitrovic/Fix10285 Issue 10285 - Enum member with a type but no identifier should not be allowed.
Comment #5 by andrej.mitrovich — 2014-04-24T21:27:45Z
Reopened, a spec pull is still needed for the second issue.
Comment #6 by briancschott — 2015-01-16T22:09:08Z
Comment #7 by github-bugzilla — 2015-01-18T07:04:13Z
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/15459d2af1349016f108b26e67be6312bef6e62c Issue 10285 - Enum grammar documentation is incorrect https://github.com/D-Programming-Language/dlang.org/commit/d054391c6b4127e8694ec805bb6fa5c41bdfd996 Merge pull request #775 from Hackerpilot/issue-10285 Issue 10285 - Enum grammar documentation is incorrect