Merge pull request #24433 from Justus2308/switch-label-halt
Sema: Fix invalid AIR generation for switch loop with comptime discarded tag
This commit is contained in:
@@ -13041,8 +13041,10 @@ fn analyzeSwitchRuntimeBlock(
|
||||
sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cases_extra.items));
|
||||
sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_body));
|
||||
|
||||
const has_any_continues = spa.operand == .loop and child_block.label.?.merges.extra_insts.items.len > 0;
|
||||
|
||||
return try child_block.addInst(.{
|
||||
.tag = if (spa.operand == .loop) .loop_switch_br else .switch_br,
|
||||
.tag = if (has_any_continues) .loop_switch_br else .switch_br,
|
||||
.data = .{ .pl_op = .{
|
||||
.operand = operand,
|
||||
.payload = payload_index,
|
||||
|
||||
@@ -216,3 +216,13 @@ test "switch loop with pointer capture" {
|
||||
try S.doTheTest();
|
||||
try comptime S.doTheTest();
|
||||
}
|
||||
|
||||
test "unanalyzed continue with operand" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
|
||||
@setRuntimeSafety(false);
|
||||
label: switch (false) {
|
||||
false => if (false) continue :label true,
|
||||
true => {},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user