Issue ID: 18578
           Summary: First enum value assigned 0 instead of
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd

The following example does not compile:

enum Foo { foo1 }
enum Bar : Foo { bar1 }

It fails with the message:

Error: cannot implicitly convert expression 0 of type int to Foo

We can fix it by changing the definition of Bar to this:

enum Bar : Foo { bar1 = Foo.init }

However, the spec ( indicates that the value
of `bar` should already have been `Foo.init`. 

> 6. The value of an EnumMember is given by its AssignExpression. If there is 
> no AssignExpression and it is the first EnumMember, its value is 
> EnumBaseType.init.

It looks like the implementation is assigning the value `0` to the first enum
value instead of EnumBaseType.init.  Either the spec is wrong or this is a bug.


Reply via email to