| author | |
| committer | |
| log | d66f13c90d4767cce3fc1e3fa94380a27f2a09b2 |
| tree | 385130550ebb3290136828095d136804aee9b24f |
| parent | f43f89a70588c2add2a7c84d12eef2852d215f51 |
| parent | b993728f10c213b679def931c2f59c8e64b14660 |
| signature |
Sema: Fix invalid AIR generation for switch loop with comptime discarded tag2 files changed, 13 insertions(+), 1 deletions(-)
src/Sema.zig+3-1| ... | @@ -13041,8 +13041,10 @@ fn analyzeSwitchRuntimeBlock( | ... | @@ -13041,8 +13041,10 @@ fn analyzeSwitchRuntimeBlock( |
| 13041 | sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cases_extra.items)); | 13041 | sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cases_extra.items)); |
| 13042 | sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_body)); | 13042 | sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_body)); |
| 13043 | 13043 | ||
| 13044 | const has_any_continues = spa.operand == .loop and child_block.label.?.merges.extra_insts.items.len > 0; | ||
| 13045 | |||
| 13044 | return try child_block.addInst(.{ | 13046 | return try child_block.addInst(.{ |
| 13045 | .tag = if (spa.operand == .loop) .loop_switch_br else .switch_br, | 13047 | .tag = if (has_any_continues) .loop_switch_br else .switch_br, |
| 13046 | .data = .{ .pl_op = .{ | 13048 | .data = .{ .pl_op = .{ |
| 13047 | .operand = operand, | 13049 | .operand = operand, |
| 13048 | .payload = payload_index, | 13050 | .payload = payload_index, |
test/behavior/switch_loop.zig+10| ... | @@ -216,3 +216,13 @@ test "switch loop with pointer capture" { | ... | @@ -216,3 +216,13 @@ test "switch loop with pointer capture" { |
| 216 | try S.doTheTest(); | 216 | try S.doTheTest(); |
| 217 | try comptime S.doTheTest(); | 217 | try comptime S.doTheTest(); |
| 218 | } | 218 | } |
| 219 | |||
| 220 | test "unanalyzed continue with operand" { | ||
| 221 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 222 | |||
| 223 | @setRuntimeSafety(false); | ||
| 224 | label: switch (false) { | ||
| 225 | false => if (false) continue :label true, | ||
| 226 | true => {}, | ||
| 227 | } | ||
| 228 | } |