diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-12-30 15:50:44 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-12-30 17:00:50 +0200 |
| commit | 67316e2eab68f19778af82018eb32af1d1b575b3 (patch) | |
| tree | 2577dbd8220646d6362657cc5f59c648e36e5ec0 /src | |
| parent | 4e64373fc07a1e24735bcbdfd463e11839c8c273 (diff) | |
| download | zig-67316e2eab68f19778af82018eb32af1d1b575b3.tar.gz zig-67316e2eab68f19778af82018eb32af1d1b575b3.zip | |
AstGen: fix `dbg_block_end` being inserted before last instruction in block
Closes #14125
Diffstat (limited to 'src')
| -rw-r--r-- | src/AstGen.zig | 10 |
1 files changed, 8 insertions, 2 deletions
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); } }; |
