authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-17 10:59:40-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-17 10:59:40-07:00
log127cd06ba1c3406a41aecae01ca32162690ab4e1
tree294823fa0e71e7955862e2a709a32e9f571591cd
parentfdd11f6cee7ef14253cef53729e09d9415b4be7e

stage2: add haveFieldTypes() assertions

This will help with contributions such as #9966.

1 files changed, 3 insertions(+), 0 deletions(-)

src/type.zig+3
......@@ -2573,12 +2573,14 @@ pub const Type = extern union {
25732573
25742574 pub fn unionFields(ty: Type) Module.Union.Fields {
25752575 const union_obj = ty.cast(Payload.Union).?.data;
2576 assert(union_obj.haveFieldTypes());
25762577 return union_obj.fields;
25772578 }
25782579
25792580 pub fn unionFieldType(ty: Type, enum_tag: Value) Type {
25802581 const union_obj = ty.cast(Payload.Union).?.data;
25812582 const index = union_obj.tag_ty.enumTagFieldIndex(enum_tag).?;
2583 assert(union_obj.haveFieldTypes());
25822584 return union_obj.fields.values()[index].ty;
25832585 }
25842586
......@@ -3376,6 +3378,7 @@ pub const Type = extern union {
33763378 .empty_struct => return .{},
33773379 .@"struct" => {
33783380 const struct_obj = ty.castTag(.@"struct").?.data;
3381 assert(struct_obj.haveFieldTypes());
33793382 return struct_obj.fields;
33803383 },
33813384 else => unreachable,