[Issue 23172] New: [REG2.100] Wrong cast inserted for ternary operator and non-int enums
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 7 22:32:53 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23172
Issue ID: 23172
Summary: [REG2.100] Wrong cast inserted for ternary operator
and non-int enums
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: johanengelen at weka.io
Testcase:
```
enum E : ubyte { // `ubyte` is needed to trigger the bug
A,
B,
}
struct S {
E e;
}
void compiles(bool b, S s) {
E e = b ? E.A : s.e;
}
void errors(bool b, const ref S s) {
E e = b ? E.A : s.e;
}
```
Errors with: <source>(15): Error: cannot implicitly convert expression `b ? 0 :
cast(int)s.e` of type `int` to `E`
Fails with LDC 1.30.0-beta1 (dlang 2.100.0), compiles succesfully with LDC 1.29
(dlang 2.099).
--
More information about the Digitalmars-d-bugs
mailing list