| ... | @@ -5101,24 +5101,22 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -5101,24 +5101,22 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 5101 | ir_mark_gen(ir_build_br(irb, payload_scope, node, cond_block, is_comptime)); | 5101 | ir_mark_gen(ir_build_br(irb, payload_scope, node, cond_block, is_comptime)); |
| 5102 | } | 5102 | } |
| 5103 | | 5103 | |
| 5104 | IrInstruction *else_result = nullptr; | 5104 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 5105 | if (else_node) { | 5105 | assert(else_node != nullptr); |
| 5106 | ir_set_cursor_at_end_and_append_block(irb, else_block); | | |
| 5107 | | 5106 | |
| 5108 | // TODO make it an error to write to error variable | 5107 | // TODO make it an error to write to error variable |
| 5109 | AstNode *err_symbol_node = else_node; // TODO make more accurate | 5108 | AstNode *err_symbol_node = else_node; // TODO make more accurate |
| 5110 | ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol, | 5109 | ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol, |
| 5111 | true, false, false, is_comptime); | 5110 | true, false, false, is_comptime); |
| 5112 | Scope *err_scope = err_var->child_scope; | 5111 | Scope *err_scope = err_var->child_scope; |
| 5113 | IrInstruction *err_var_value = ir_build_unwrap_err_code(irb, err_scope, err_symbol_node, err_val_ptr); | 5112 | IrInstruction *err_var_value = ir_build_unwrap_err_code(irb, err_scope, err_symbol_node, err_val_ptr); |
| 5114 | ir_build_var_decl(irb, err_scope, symbol_node, err_var, nullptr, nullptr, err_var_value); | 5113 | ir_build_var_decl(irb, err_scope, symbol_node, err_var, nullptr, nullptr, err_var_value); |
| 5115 | | 5114 | |
| 5116 | else_result = ir_gen_node(irb, else_node, err_scope); | 5115 | IrInstruction *else_result = ir_gen_node(irb, else_node, err_scope); |
| 5117 | if (else_result == irb->codegen->invalid_instruction) | 5116 | if (else_result == irb->codegen->invalid_instruction) |
| 5118 | return else_result; | 5117 | return else_result; |
| 5119 | if (!instr_is_unreachable(else_result)) | 5118 | if (!instr_is_unreachable(else_result)) |
| 5120 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); | 5119 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); |
| 5121 | } | | |
| 5122 | IrBasicBlock *after_else_block = irb->current_basic_block; | 5120 | IrBasicBlock *after_else_block = irb->current_basic_block; |
| 5123 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 5121 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 5124 | if (else_result) { | 5122 | if (else_result) { |