| ... | @@ -1210,6 +1210,12 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool { | ... | @@ -1210,6 +1210,12 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool { |
| 1210 | | 1210 | |
| 1211 | try self.astGenBlock(&gen_scope.base, body_block); | 1211 | try self.astGenBlock(&gen_scope.base, body_block); |
| 1212 | | 1212 | |
| | 1213 | const last_inst = gen_scope.instructions.items[gen_scope.instructions.items.len - 1]; |
| | 1214 | if (!last_inst.tag.isNoReturn()) { |
| | 1215 | const src = tree.token_locs[body_block.rbrace].start; |
| | 1216 | _ = try self.addZIRInst(&gen_scope.base, src, zir.Inst.ReturnVoid, .{}, .{}); |
| | 1217 | } |
| | 1218 | |
| 1213 | const fn_zir = try gen_scope_arena.allocator.create(Fn.ZIR); | 1219 | const fn_zir = try gen_scope_arena.allocator.create(Fn.ZIR); |
| 1214 | fn_zir.* = .{ | 1220 | fn_zir.* = .{ |
| 1215 | .body = .{ | 1221 | .body = .{ |
| ... | @@ -2686,7 +2692,7 @@ fn analyzeInstBlock(self: *Module, scope: *Scope, inst: *zir.Inst.Block) InnerEr | ... | @@ -2686,7 +2692,7 @@ fn analyzeInstBlock(self: *Module, scope: *Scope, inst: *zir.Inst.Block) InnerEr |
| 2686 | | 2692 | |
| 2687 | // Blocks must terminate with noreturn instruction. | 2693 | // Blocks must terminate with noreturn instruction. |
| 2688 | assert(child_block.instructions.items.len != 0); | 2694 | assert(child_block.instructions.items.len != 0); |
| 2689 | assert(child_block.instructions.items[child_block.instructions.items.len - 1].tag.isNoReturn()); | 2695 | assert(child_block.instructions.items[child_block.instructions.items.len - 1].ty.isNoReturn()); |
| 2690 | | 2696 | |
| 2691 | // Need to set the type and emit the Block instruction. This allows machine code generation | 2697 | // Need to set the type and emit the Block instruction. This allows machine code generation |
| 2692 | // to emit a jump instruction to after the block when it encounters the break. | 2698 | // to emit a jump instruction to after the block when it encounters the break. |
| ... | @@ -3271,7 +3277,7 @@ fn analyzeInstCondBr(self: *Module, scope: *Scope, inst: *zir.Inst.CondBr) Inner | ... | @@ -3271,7 +3277,7 @@ fn analyzeInstCondBr(self: *Module, scope: *Scope, inst: *zir.Inst.CondBr) Inner |
| 3271 | defer false_block.instructions.deinit(self.gpa); | 3277 | defer false_block.instructions.deinit(self.gpa); |
| 3272 | try self.analyzeBody(&false_block.base, inst.positionals.false_body); | 3278 | try self.analyzeBody(&false_block.base, inst.positionals.false_body); |
| 3273 | | 3279 | |
| 3274 | return self.addNewInstArgs(parent_block, inst.base.src, Type.initTag(.void), Inst.CondBr, Inst.Args(Inst.CondBr){ | 3280 | return self.addNewInstArgs(parent_block, inst.base.src, Type.initTag(.noreturn), Inst.CondBr, Inst.Args(Inst.CondBr){ |
| 3275 | .condition = cond, | 3281 | .condition = cond, |
| 3276 | .true_body = .{ .instructions = try scope.arena().dupe(*Inst, true_block.instructions.items) }, | 3282 | .true_body = .{ .instructions = try scope.arena().dupe(*Inst, true_block.instructions.items) }, |
| 3277 | .false_body = .{ .instructions = try scope.arena().dupe(*Inst, false_block.instructions.items) }, | 3283 | .false_body = .{ .instructions = try scope.arena().dupe(*Inst, false_block.instructions.items) }, |