From 727af307c62d33f7bd9ee9ce45b81481a9479b86 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 21 Jun 2019 18:21:12 -0400 Subject: fix return result loc and then switch with range... ...implicit casted to error union --- src/ir.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index a6ec836a40..08253e7487 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7115,8 +7115,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * assert(ok_bit); assert(last_item_node); - ir_mark_gen(ir_build_cond_br(irb, scope, last_item_node, ok_bit, range_block_yes, - range_block_no, is_comptime)); + IrInstruction *br_inst = ir_mark_gen(ir_build_cond_br(irb, scope, last_item_node, ok_bit, + range_block_yes, range_block_no, is_comptime)); + if (peer_parent->base.source_instruction == nullptr) { + peer_parent->base.source_instruction = br_inst; + } if (peer_parent->peers.length > 0) { peer_parent->peers.last()->next_bb = range_block_yes; @@ -7198,10 +7201,12 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * } br_instruction = &switch_br->base; } + if (peer_parent->base.source_instruction == nullptr) { + peer_parent->base.source_instruction = br_instruction; + } for (size_t i = 0; i < peer_parent->peers.length; i += 1) { - peer_parent->peers.at(i)->base.source_instruction = br_instruction; + peer_parent->peers.at(i)->base.source_instruction = peer_parent->base.source_instruction; } - peer_parent->base.source_instruction = br_instruction; if (!else_prong) { if (peer_parent->peers.length != 0) { -- cgit v1.2.3