Skip to content

Commit 5748504

Browse files
dkorpelclaude
authored andcommitted
Fix #21637 - ICE in tuple comparison with conditional expression
In `elcond`, when restructuring `((a,b) ? c : d)` into `(a, (b ? c : d))`, `Ety` was copied to the new inner OPcond but `ET` was not. This left the OPcond with TYstruct Ety but null ET, causing `elstruct` to return early and `exp2_copytotemp` to crash with `assert(ty != TYstruct)`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7848b5e commit 5748504

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

compiler/src/dmd/backend/cgelem.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,7 @@ private elem* elcond(elem* e, Goal goal)
21392139
e.E2 = e1;
21402140
e1.Eoper = OPcond;
21412141
e1.Ety = e.Ety;
2142+
e1.ET = e.ET;
21422143
return optelem(e, Goal.value);
21432144

21442145
case OPnot:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://github.com/dlang/dmd/issues/21637
2+
// ICE in tuple comparison with conditional expression
3+
4+
struct Date {
5+
short _year = 1;
6+
ubyte _month;
7+
ubyte _day = 1;
8+
9+
this(int day) { }
10+
}
11+
12+
struct Nullable(T){
13+
T t;
14+
short b;
15+
}
16+
17+
struct DateRange {
18+
Nullable!Date end;
19+
}
20+
21+
void main()
22+
{
23+
auto thing = DateRange(
24+
(Date(1).tupleof == Date(2).tupleof) ? Nullable!Date() : Nullable!Date()
25+
);
26+
}

0 commit comments

Comments
 (0)