| ... | @@ -5225,17 +5225,17 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -5225,17 +5225,17 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError |
| 5225 | | 5225 | |
| 5226 | try sema.analyzeBody(&loop_block, body); | 5226 | try sema.analyzeBody(&loop_block, body); |
| 5227 | | 5227 | |
| 5228 | if (sema.typeOf(Air.indexToRef(loop_block.instructions.items[loop_block.instructions.items.len - 1])).isNoReturn()) { | 5228 | const loop_block_len = loop_block.instructions.items.len; |
| | 5229 | if (loop_block_len > 0 and sema.typeOf(Air.indexToRef(loop_block.instructions.items[loop_block_len - 1])).isNoReturn()) { |
| 5229 | // If the loop ended with a noreturn terminator, then there is no way for it to loop, | 5230 | // If the loop ended with a noreturn terminator, then there is no way for it to loop, |
| 5230 | // so we can just use the block instead. | 5231 | // so we can just use the block instead. |
| 5231 | try child_block.instructions.appendSlice(gpa, loop_block.instructions.items); | 5232 | try child_block.instructions.appendSlice(gpa, loop_block.instructions.items); |
| 5232 | } else { | 5233 | } else { |
| 5233 | try child_block.instructions.append(gpa, loop_inst); | 5234 | try child_block.instructions.append(gpa, loop_inst); |
| 5234 | | 5235 | |
| 5235 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + | 5236 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + loop_block_len); |
| 5236 | loop_block.instructions.items.len); | | |
| 5237 | sema.air_instructions.items(.data)[loop_inst].ty_pl.payload = sema.addExtraAssumeCapacity( | 5237 | sema.air_instructions.items(.data)[loop_inst].ty_pl.payload = sema.addExtraAssumeCapacity( |
| 5238 | Air.Block{ .body_len = @intCast(u32, loop_block.instructions.items.len) }, | 5238 | Air.Block{ .body_len = @intCast(u32, loop_block_len) }, |
| 5239 | ); | 5239 | ); |
| 5240 | sema.air_extra.appendSliceAssumeCapacity(loop_block.instructions.items); | 5240 | sema.air_extra.appendSliceAssumeCapacity(loop_block.instructions.items); |
| 5241 | } | 5241 | } |