www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2351] New: enum with no members allowed

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2351

           Summary: enum with no members allowed
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: tomas famolsen.dk


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;


-- 
Sep 10 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2351


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |spec




------- Comment #1 from smjg iname.com  2008-10-25 07:33 -------
Either this is a contradiction in the spec, or we need clarification of what
';' as an EnumBody means.


-- 
Oct 25 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2351


Jerry Quinn <jlquinn optonline.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://digitalmars.com/d/2.
                   |                            |0/enum.html
                 CC|                            |jlquinn optonline.net


--- Comment #2 from Jerry Quinn <jlquinn optonline.net> 2010-02-22 04:58:09 PST
---
This would be fixed by changing the EnumBody rule to

EnumBody:
  EnumMember ;
  { EnumMembers }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2351



--- Comment #3 from Stewart Gordon <smjg iname.com> 2010-02-22 08:07:25 PST ---
So the meaning of that code changes from declaring an enum type with no members
to declaring a manifest constant with value 0.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2351



--- Comment #4 from Jerry Quinn <jlquinn optonline.net> 2010-02-26 05:29:58 PST
---
(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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 26 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2351



--- Comment #5 from Jerry Quinn <jlquinn optonline.net> 2010-02-26 05:35:27 PST
---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 26 2010