[Issue 24850] New: Named enum construction from base type is inconsistent
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Nov 9 16:35:12 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24850
Issue ID: 24850
Summary: Named enum construction from base type is inconsistent
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: nick at geany.org
The following is an error:
```
enum E : int;
E e = E(4);
```
enumbase.d(2): Error: cannot implicitly convert expression `4` of type `int` to
`E`
Which is consistent with uniform construction because a base type instance does
not implicitly convert to the enum type. But this compiles:
```
struct S {
this(int) {}
}
enum E : S;
E e = E(2);
```
However, an instance of S does not implicitly convert to E, so this is
inconsistent.
The spec does not seem to mention enum construction with an argument list.
There is a test in dmd for issue 16346 to allow E(E.member), presumably for
generic code.
--
More information about the Digitalmars-d-bugs
mailing list