From c961124d93a47e9ae317b2e057cf0fe5118303e3 Mon Sep 17 00:00:00 2001 From: Matthew Lugg Date: Mon, 31 Aug 2026 10:40:27 +0100 Subject: [PATCH] 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`. --- src/Type.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Type.zig b/src/Type.zig index f455bfa8ddee03df753592c9303d1ed0fb5a5df2..f57216168a306d75648fb37ce18ad1770d35892f 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -209,6 +209,7 @@ pub fn classify(start_ty: Type, zcu: *const Zcu) Class { const struct_obj = ip.loadStructType(cur_ty.toIntern()); switch (struct_obj.layout) { .auto, .@"extern" => { + assert(struct_obj.want_layout); zcu.assertUpToDate(.wrap(.{ .type_layout = cur_ty.toIntern() })); break struct_obj.class; }, @@ -222,6 +223,7 @@ pub fn classify(start_ty: Type, zcu: *const Zcu) Class { const union_obj = ip.loadUnionType(cur_ty.toIntern()); switch (union_obj.layout) { .auto, .@"extern" => { + assert(union_obj.want_layout); zcu.assertUpToDate(.wrap(.{ .type_layout = cur_ty.toIntern() })); break union_obj.class; }, @@ -232,8 +234,10 @@ pub fn classify(start_ty: Type, zcu: *const Zcu) Class { } }, .enum_type => { + const enum_obj = ip.loadEnumType(cur_ty.toIntern()); + assert(enum_obj.want_layout); zcu.assertUpToDate(.wrap(.{ .type_layout = cur_ty.toIntern() })); - cur_ty = .fromInterned(ip.loadEnumType(cur_ty.toIntern()).int_tag_type); + cur_ty = .fromInterned(enum_obj.int_tag_type); continue; }, -- 2.54.0