[Issue 23981] enum siblings and struct member naming conflict undetected and counter intuitive path prefered

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 9 19:45:28 UTC 2023


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

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel at live.nl
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Dennis <dkorpel at live.nl> ---
I reduced the example a bit:

```D
struct B
{
    int j;
    bool down() {return true;}
}

enum button
{
    shift = B(0),
    down = B(1), // without this line, it compiles
}

void main()
{
    // Error: struct `B` does not overload ()
    if (button.shift.down()) {}
}
```

This is indeed very confusing, and a result of D allowing you to access static
properties of a type using an instance of that type. I don't know if the
specification says one of them is supposed to have priority.

--


More information about the Digitalmars-d-bugs mailing list