aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-17 10:59:40 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-10-17 10:59:40 -0700
commit127cd06ba1c3406a41aecae01ca32162690ab4e1 (patch)
tree294823fa0e71e7955862e2a709a32e9f571591cd /src
parentfdd11f6cee7ef14253cef53729e09d9415b4be7e (diff)
downloadzig-127cd06ba1c3406a41aecae01ca32162690ab4e1.tar.gz
zig-127cd06ba1c3406a41aecae01ca32162690ab4e1.zip
stage2: add haveFieldTypes() assertions
This will help with contributions such as #9966.
Diffstat (limited to 'src')
-rw-r--r--src/type.zig3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig
index d845d8a49a..be3fc1df67 100644
--- 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,