zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 67316e2eab68f19778af82018eb32af1d1b575b3 (tree)
parent 4e64373fc07a1e24735bcbdfd463e11839c8c273
Author: Veikka Tuominen <git@vexu.eu>
Date:   Fri, 30 Dec 2022 15:50:44 +0200

AstGen: fix `dbg_block_end` being inserted before last instruction in block

Closes #14125

Diffstat:
Msrc/AstGen.zig | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git 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); } };