www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23862] New: with statement should accept an expression with

https://issues.dlang.org/show_bug.cgi?id=23862

          Issue ID: 23862
           Summary: with statement should accept an expression with enum
                    type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

enum E { A, B }

  void test(E e) {
    with (e)
    switch (e) {
        case A:
        case B:
        default:
            break;
    }
  }

fails with:

  Error: `with` expressions must be aggregate types or pointers to them, not
`E`

This should work.

--
Apr 25 2023