Propagate errors in for loop bodies

Closes #3819
This commit is contained in:
LemonBoy
2020-01-12 15:04:43 +01:00
committed by Andrew Kelley
parent c4770e7aa5
commit c96131f30c
2 changed files with 11 additions and 0 deletions

View File

@@ -7456,6 +7456,8 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
// it's actually in break statements, handled similarly to return statements.
// That is why we set those values in loop_scope above and not in this ir_gen_node call.
IrInstruction *body_result = ir_gen_node(irb, body_node, &loop_scope->base);
if (body_result == irb->codegen->invalid_instruction)
return irb->codegen->invalid_instruction;
if (!instr_is_unreachable(body_result)) {
ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.for_expr.body, body_result));