Bug 1112 – Allow enums in WithStatements

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-04-08T11:51:00Z
Last change time
2015-06-09T05:15:03Z
Assigned to
nobody
Creator
matti.niemenmaa+dbugzilla

Comments

Comment #0 by matti.niemenmaa+dbugzilla — 2007-04-08T11:51:36Z
Been asked for a few times, submitting it here for posterity. enum Enum { A = 0, B, C } void main() { with (Enum) { assert (A == 0); assert (B == A+1); assert (C == B+1); } } It would be handy if the above worked. A common use case is switching on an enum: enum Enum { A = 0, B, C } void main() { Enum e; with (Enum) switch (e) { case A: case B: case C: default: break; } // the above looks much better than: switch (e) { case Enum.A: case Enum.B: case Enum.C: default: break; } }
Comment #1 by ary — 2007-04-08T13:25:24Z
Comment #2 by aifgi90 — 2010-02-14T18:00:46Z
Works with DMD 1.055 and DMD 2.040