digitalmars.D.bugs - [Issue 22665] New: ImportC: enums are not "implicitly converting" to
- d-bugmail puremagic.com (37/37) Jan 11 2022 https://issues.dlang.org/show_bug.cgi?id=22665
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 puremagic.com Reporter: dave287091 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. --
Jan 11 2022