[Issue 22665] New: ImportC: enums are not "implicitly converting" to their own type.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 11 08:59:15 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22665
Issue ID: 22665
Summary: ImportC: enums are not "implicitly converting" to
their own type.
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
Consider the following:
// an_enum.c
enum AnEnum {
A = 0,
B = 1,
};
// use_an_enum.d
import an_enum;
int foo(AnEnum e){
AnEnum ae = AnEnum.A; // Error: cannot implicitly convert expression `0` of
type `int` to `AnEnum`
switch(e){
case AnEnum.A: // Error: cannot implicitly convert expression `0` of
type `int` to `AnEnum`
return 1;
case AnEnum.B: // Error: cannot implicitly convert expression `1` of
type `int` to `AnEnum`
return 2;
}
}
As one of the major benefits of ImportC is getting access to enums defined in
C, this is a major problem.
--
More information about the Digitalmars-d-bugs
mailing list