| ... | @@ -2738,12 +2738,14 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco | ... | @@ -2738,12 +2738,14 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco |
| 2738 | } | 2738 | } |
| 2739 | } | 2739 | } |
| 2740 | | 2740 | |
| 2741 | static void ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, | 2741 | static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, |
| 2742 | bool gen_error_defers, bool gen_maybe_defers) | 2742 | bool gen_error_defers, bool gen_maybe_defers) |
| 2743 | { | 2743 | { |
| 2744 | Scope *scope = inner_scope; | 2744 | Scope *scope = inner_scope; |
| 2745 | while (scope != outer_scope) { | 2745 | while (scope != outer_scope) { |
| 2746 | assert(scope); | 2746 | if (!scope) |
| | 2747 | return false; |
| | 2748 | |
| 2747 | if (scope->id == ScopeIdDefer) { | 2749 | if (scope->id == ScopeIdDefer) { |
| 2748 | AstNode *defer_node = scope->source_node; | 2750 | AstNode *defer_node = scope->source_node; |
| 2749 | assert(defer_node->type == NodeTypeDefer); | 2751 | assert(defer_node->type == NodeTypeDefer); |
| ... | @@ -2759,6 +2761,7 @@ static void ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -2759,6 +2761,7 @@ static void ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 2759 | } | 2761 | } |
| 2760 | scope = scope->parent; | 2762 | scope = scope->parent; |
| 2761 | } | 2763 | } |
| | 2764 | return true; |
| 2762 | } | 2765 | } |
| 2763 | | 2766 | |
| 2764 | static void ir_set_cursor_at_end(IrBuilder *irb, IrBasicBlock *basic_block) { | 2767 | static void ir_set_cursor_at_end(IrBuilder *irb, IrBasicBlock *basic_block) { |
| ... | @@ -5105,7 +5108,11 @@ static bool ir_goto_pass2(IrBuilder *irb) { | ... | @@ -5105,7 +5108,11 @@ static bool ir_goto_pass2(IrBuilder *irb) { |
| 5105 | | 5108 | |
| 5106 | IrInstruction *is_comptime = ir_build_const_bool(irb, goto_item->scope, source_node, | 5109 | IrInstruction *is_comptime = ir_build_const_bool(irb, goto_item->scope, source_node, |
| 5107 | ir_should_inline(irb) || source_node->data.goto_expr.is_inline); | 5110 | ir_should_inline(irb) || source_node->data.goto_expr.is_inline); |
| 5108 | ir_gen_defers_for_block(irb, goto_item->scope, label->bb->scope, false, false); | 5111 | if (!ir_gen_defers_for_block(irb, goto_item->scope, label->bb->scope, false, false)) { |
| | 5112 | add_node_error(irb->codegen, source_node, |
| | 5113 | buf_sprintf("no label in scope named '%s'", buf_ptr(label_name))); |
| | 5114 | return false; |
| | 5115 | } |
| 5109 | ir_build_br(irb, goto_item->scope, source_node, label->bb, is_comptime); | 5116 | ir_build_br(irb, goto_item->scope, source_node, label->bb, is_comptime); |
| 5110 | } | 5117 | } |
| 5111 | | 5118 | |