Summary: It should be illegal for enums to declare members
                    named init, max, or min
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from Jonathan M Davis <> 2012-10-13 23:57:05 
PDT ---
TDPL (p.275) specifically allows for enums to declare members named min, max,
and init and then immediately tells you that it's a dumb idea to do so.
Allowing it is bound to break generic code, since it allows you to do nonsense

enum MyEnum : int {max, min, init}

completely breaking any guarantees about what the mean. And note this fun

enum MyEnum : int { a, b, c, init }

void main()
    MyEnum e;
    assert(e == MyEnum.a);
    assert(MyEnum.init == MyEnum.a);

The first assertion passes and the second fails, meaning that the declartion of
init has effectively hidden the real init. I'd strongly argue that allowing the
overloading init, min, and max should be disallowed. Allowing it gains us
nothing and just causes bugs.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to