aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-07-16 19:35:31 +0100
committermlugg <mlugg@mlugg.co.uk>2024-07-16 19:44:15 +0100
commit5093a5cd193ed3cd4107f0fcdb0ed1ab9dda30f5 (patch)
treee7ae983fd3a20ba67dafad3062a3cbf0c2e2473e
parentee695c8ef40ae7cecb4b9a77c8a6dcbe53d4f013 (diff)
downloadzig-5093a5cd193ed3cd4107f0fcdb0ed1ab9dda30f5.tar.gz
zig-5093a5cd193ed3cd4107f0fcdb0ed1ab9dda30f5.zip
std.Zir: some declaration traversal fixes
-rw-r--r--lib/std/zig/Zir.zig29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig
index 600ca488e6..128e91eef4 100644
--- a/lib/std/zig/Zir.zig
+++ b/lib/std/zig/Zir.zig
@@ -3791,11 +3791,15 @@ fn findDeclsSwitch(
break :blk multi_cases_len;
} else 0;
+ if (extra.data.bits.any_has_tag_capture) {
+ extra_index += 1;
+ }
+
const special_prong = extra.data.bits.specialProng();
if (special_prong != .none) {
- const body_len: u31 = @truncate(zir.extra[extra_index]);
+ const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]);
extra_index += 1;
- const body = zir.bodySlice(extra_index, body_len);
+ const body = zir.bodySlice(extra_index, prong_info.body_len);
extra_index += body.len;
try zir.findDeclsBody(list, body);
@@ -3805,10 +3809,10 @@ fn findDeclsSwitch(
const scalar_cases_len = extra.data.bits.scalar_cases_len;
for (0..scalar_cases_len) |_| {
extra_index += 1;
- const body_len: u31 = @truncate(zir.extra[extra_index]);
+ const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]);
extra_index += 1;
- const body = zir.bodySlice(extra_index, body_len);
- extra_index += body_len;
+ const body = zir.bodySlice(extra_index, prong_info.body_len);
+ extra_index += body.len;
try zir.findDeclsBody(list, body);
}
@@ -3819,20 +3823,13 @@ fn findDeclsSwitch(
extra_index += 1;
const ranges_len = zir.extra[extra_index];
extra_index += 1;
- const body_len: u31 = @truncate(zir.extra[extra_index]);
+ const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]);
extra_index += 1;
- const items = zir.refSlice(extra_index, items_len);
- extra_index += items_len;
- _ = items;
- var range_i: usize = 0;
- while (range_i < ranges_len) : (range_i += 1) {
- extra_index += 1;
- extra_index += 1;
- }
+ extra_index += items_len + ranges_len * 2;
- const body = zir.bodySlice(extra_index, body_len);
- extra_index += body_len;
+ const body = zir.bodySlice(extra_index, prong_info.body_len);
+ extra_index += body.len;
try zir.findDeclsBody(list, body);
}