diff --git a/src/AstGen.zig b/src/AstGen.zig index e70424188a..91dea526dc 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -6942,7 +6942,13 @@ fn switchExpr( // it as the break operand. if (body_len < 2) break :blk; - const store_inst = payloads.items[end_index - 2]; + + var store_index = end_index - 2; + while (true) : (store_index -= 1) switch (zir_tags[payloads.items[store_index]]) { + .dbg_block_end, .dbg_block_begin, .dbg_stmt, .dbg_var_val, .dbg_var_ptr => {}, + else => break, + }; + const store_inst = payloads.items[store_index]; if (zir_tags[store_inst] != .store_to_block_ptr or zir_datas[store_inst].bin.lhs != block_scope.rl_ptr) break :blk; @@ -12150,7 +12156,7 @@ const GenZir = struct { const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len); try gz.astgen.instructions.append(gpa, .{ .tag = .dbg_block_end, .data = undefined }); - try gz.instructions.insert(gpa, gz.instructions.items.len - 1, new_index); + try gz.instructions.append(gpa, new_index); } };