[Issue 10555] enumerator can no longer increment beyond maximum of initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 31 04:16:05 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10555


Henning Pohl <henning at still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |henning at still-hidden.de


--- Comment #3 from Henning Pohl <henning at still-hidden.de> 2013-08-31 04:16:03 PDT ---
I think this behaviour is correct:

Spec:
----
If the EnumBaseType is not explicitly set, and the first EnumMember has an
initializer, it is set to the type of that initializer. Otherwise, it defaults
to type int.

Named enum members may not have individual Types.

A named enum member can be implicitly cast to its EnumBaseType, but
EnumBaseType types cannot be implicitly cast to an enum type.
----

The behaviour before issue 3096 always used int as EnumBaseType even though
there is a first initializer.

enum A // int
{
    A0
}
enum B // A
{
    B0 = A.A0,
    B1
}

In this case the base type of B is A and A does not have a member whith a value
of 1.

enum A // int
{
    A0
}
enum B // A
{
    B0 = A.A0,
    B1 = A.A0 + 1
}

This is basically the same case as above.

enum A // int
{
    A0
}

enum B // int
{
    B0 = A.A0 + 0,
    B1
}

This works because the type of the first initializer is int. So the base type
of B becomes int and ints can be incremented easily.

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


More information about the Digitalmars-d-bugs mailing list