Skip to content

Commit 3d26d8c

Browse files
committed
sema: inherit block want_safety for err switch union
1 parent abb1913 commit 3d26d8c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Sema.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11258,6 +11258,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
1125811258
.runtime_loop = block.runtime_loop,
1125911259
.runtime_index = block.runtime_index,
1126011260
.error_return_trace_index = block.error_return_trace_index,
11261+
.want_safety = block.want_safety,
1126111262
};
1126211263
const merges = &child_block.label.?.merges;
1126311264
defer child_block.instructions.deinit(gpa);

test/cases/inherit_want_safety.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ pub export fn entry() usize {
2323
u += 1;
2424
},
2525
}
26+
if (@as(error{}!usize, u)) |_| {
27+
u += 1;
28+
} else |e| switch (e) {
29+
else => {
30+
u += 1;
31+
}
32+
}
2633
return u;
2734
}
2835

0 commit comments

Comments
 (0)