www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23546] New: bad error message for forward referenced member

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

          Issue ID: 23546
           Summary: bad error message for forward referenced member in
                    enum
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: nick geany.org

From: https://dlang.org/spec/enum.html#named_enums

enum C
{
    A = B,  // A = 4
    B = D,  // B = 4
    C = 3,  // C = 3
    D       // D = 4
}

This causes:
enumerr.d(6): Error: cannot implicitly convert expression `4` of type `int` to
`C`

Note A does not affect this bug.

Either:
* dmd should allow this
* dmd should give a better error message and the spec should be updated.

--
Dec 10 2022