[Issue 24656] enums with explicit EnumBaseType incorrectly matching multiple overloads.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 9 23:37:28 UTC 2024


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

--- Comment #6 from basile-z <b2.temp at gmx.com> ---
(In reply to dave287091 from comment #5)
> (In reply to basile-z from comment #4)
> > Also "to which point enum members are strongly-typed ?" is the underlying
> > question. You expect some kind of VRP (or maybe constant folding) but that
> > is not the case.
> 
> I expect that specifying a base type means that enum is converted to that
> type before any other implicit conversion.

That goes a bit against how subtyping works:

```
class A {}
class B : A {}

void test(A a){ assert(0, "no the top-most type is tried first"); }
void test(B b){}

void main(){(new B).test();}          
```

That being said, I'll stop to argument there. I'm not a big fan of the
overloading principle. The issue you've opened is exactly what it leads to, i.e
confusion.

Side note: sure in D it's a bit more complex, as overloading participate to
pick the right template, based on how constraints are evaluated ;)

--


More information about the Digitalmars-d-bugs mailing list