Thread overview
[Issue 23522] Error message when enum type is not integral and a value lacks an initializer
Dec 01, 2022
RazvanN
Dec 17, 2022
Iain Buclaw
Dec 17, 2022
Iain Buclaw
Jan 02, 2023
Basile-z
Sep 08, 2023
Dlang Bot
Sep 08, 2023
Nick Treleaven
Sep 08, 2023
Dlang Bot
December 01, 2022
https://issues.dlang.org/show_bug.cgi?id=23522

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bootcamp
                 CC|                            |razvan.nitu1305@gmail.com

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=23522

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=23522

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

--
January 02, 2023
https://issues.dlang.org/show_bug.cgi?id=23522

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |b2.temp@gmx.com
           Severity|trivial                     |normal

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
semantics are more subtle, the increment from the previous value can work for non-integral types too:

```
struct FooInt
{
    int i;
    auto opBinary(string op : "+")(int j)
    {
        return typeof(this)(i + j);
    }

    static @property FooInt max()
    {
        return typeof(this)(int.max);
    }
}

enum foolist
{
    hi  = FooInt(0),
    bye
}
```

So you can only determine if the implicit value can be set by trying it.

--
September 08, 2023
https://issues.dlang.org/show_bug.cgi?id=23522

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ntrel created dlang/dmd pull request #15588 "Improve error messages when enum member cannot be generated" fixing this issue:

- Fix Issue 23522 - Error message when enum type is not integral and a value lacks an initializer

https://github.com/dlang/dmd/pull/15588

--
September 08, 2023
https://issues.dlang.org/show_bug.cgi?id=23522

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #3 from Nick Treleaven <nick@geany.org> ---
With the PR, dmd will give introductory errors which should help the others make sense:

enumstr.d(4): Error: cannot check `enumstr.X.b` value for overflow
enumstr.d(1): Error: no property `max` for type `string`, perhaps `import
std.algorithm;` is needed?
enumstr.d(4): Error: cannot generate value for `enumstr.X.b`
enumstr.d(4): Error: incompatible types for `("a") + (1)`: `X` and `int`

--
September 08, 2023
https://issues.dlang.org/show_bug.cgi?id=23522

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15588 "Improve error messages when enum member cannot be generated" was merged into master:

- fecd435f695f030ac4d1de548bb00e4f690dfacd by Nick Treleaven:
  Fix Issue 23522 - Error message when enum type is not integral and a value
lacks an initializer

https://github.com/dlang/dmd/pull/15588

--