authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-31 10:40:27+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-09-01 21:17:00+02:00
logc961124d93a47e9ae317b2e057cf0fe5118303e3
treef4968396923b9f78d7b088436841039241c755a7
parent0a2af0b09a435e95f07fb4624ed1ee1025761a4e

Type: fix layout resolution assertion in `classify`

First spotted in https://codeberg.org/ziglang/zig/pulls/36643, where the author noticed that the assertion in `classify` wasn't tripping when it should have been (which would have made the bug more obvious!). I think that back when I was reworking type resolution, I changed how these assertions worked at some point, and updated `assertHasLayout`, but failed to update the similar logic in `classify`.

1 files changed, 5 insertions(+), 1 deletions(-)

src/Type.zig+5-1
......@@ -209,6 +209,7 @@ pub fn classify(start_ty: Type, zcu: *const Zcu) Class {
209209 const struct_obj = ip.loadStructType(cur_ty.toIntern());
210210 switch (struct_obj.layout) {
211211 .auto, .@"extern" => {
212 assert(struct_obj.want_layout);
212213 zcu.assertUpToDate(.wrap(.{ .type_layout = cur_ty.toIntern() }));
213214 break struct_obj.class;
214215 },
......@@ -222,6 +223,7 @@ pub fn classify(start_ty: Type, zcu: *const Zcu) Class {
222223 const union_obj = ip.loadUnionType(cur_ty.toIntern());
223224 switch (union_obj.layout) {
224225 .auto, .@"extern" => {
226 assert(union_obj.want_layout);
225227 zcu.assertUpToDate(.wrap(.{ .type_layout = cur_ty.toIntern() }));
226228 break union_obj.class;
227229 },
......@@ -232,8 +234,10 @@ pub fn classify(start_ty: Type, zcu: *const Zcu) Class {
232234 }
233235 },
234236 .enum_type => {
237 const enum_obj = ip.loadEnumType(cur_ty.toIntern());
238 assert(enum_obj.want_layout);
235239 zcu.assertUpToDate(.wrap(.{ .type_layout = cur_ty.toIntern() }));
236 cur_ty = .fromInterned(ip.loadEnumType(cur_ty.toIntern()).int_tag_type);
240 cur_ty = .fromInterned(enum_obj.int_tag_type);
237241 continue;
238242 },
239243