File tree 2 files changed +41
-3
lines changed
2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -1107,9 +1107,14 @@ MATCH implicitConvTo(Expression e, Type t)
1107
1107
1108
1108
MATCH visitCond (CondExp e)
1109
1109
{
1110
- auto result = visit(e);
1111
- if (result != MATCH .nomatch)
1112
- return result;
1110
+ e.econd = e.econd.optimize(WANTvalue);
1111
+ const opt = e.econd.toBool();
1112
+ if (opt.isPresent())
1113
+ {
1114
+ auto result = visit(e);
1115
+ if (result != MATCH .nomatch)
1116
+ return result;
1117
+ }
1113
1118
1114
1119
MATCH m1 = e.e1.implicitConvTo(t);
1115
1120
MATCH m2 = e.e2.implicitConvTo(t);
Original file line number Diff line number Diff line change
1
+ // https://issues.dlang.org/show_bug.cgi?id=23172
2
+
3
+ enum E : ubyte { // `ubyte` is needed to trigger the bug
4
+ A,
5
+ B,
6
+ }
7
+
8
+ struct S {
9
+ E e;
10
+ }
11
+
12
+ void compiles (bool b, S s) {
13
+ E e = b ? E.A : s.e;
14
+ }
15
+
16
+ void errors (bool b, const ref S s) {
17
+ E e = b ? E.A : s.e;
18
+ }
19
+
20
+ // from https://issues.dlang.org/show_bug.cgi?id=23188
21
+
22
+ enum Status : byte
23
+ {
24
+ A, B, C
25
+ }
26
+
27
+ Status foo ()
28
+ {
29
+ Status t = Status.A;
30
+ const Status s = t;
31
+
32
+ return (s == Status.A) ? Status.B : s; // <-- here
33
+ }
You can’t perform that action at this time.
0 commit comments