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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 2 12:17:14 UTC 2023


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

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

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

--- Comment #1 from Basile-z <b2.temp at 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.

--


More information about the Digitalmars-d-bugs mailing list