commit 127cd06ba1c3406a41aecae01ca32162690ab4e1 (tree)
parent fdd11f6cee7ef14253cef53729e09d9415b4be7e
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sun, 17 Oct 2021 10:59:40 -0700
stage2: add haveFieldTypes() assertions
This will help with contributions such as #9966.
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/type.zig b/src/type.zig
@@ -2573,12 +2573,14 @@ pub const Type = extern union {
pub fn unionFields(ty: Type) Module.Union.Fields {
const union_obj = ty.cast(Payload.Union).?.data;
+ assert(union_obj.haveFieldTypes());
return union_obj.fields;
}
pub fn unionFieldType(ty: Type, enum_tag: Value) Type {
const union_obj = ty.cast(Payload.Union).?.data;
const index = union_obj.tag_ty.enumTagFieldIndex(enum_tag).?;
+ assert(union_obj.haveFieldTypes());
return union_obj.fields.values()[index].ty;
}
@@ -3376,6 +3378,7 @@ pub const Type = extern union {
.empty_struct => return .{},
.@"struct" => {
const struct_obj = ty.castTag(.@"struct").?.data;
+ assert(struct_obj.haveFieldTypes());
return struct_obj.fields;
},
else => unreachable,