aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-02-26 18:01:12 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-02-26 20:59:23 -0700
commit32e89a98d82c0f4505a3f3d4cd72e7db2eadfbb9 (patch)
treead3f28c440c3ff6e1ad5cfd5bb05a867331e4b0e /src/type.zig
parente999a925fade363886538722df7605b01da220d1 (diff)
downloadzig-32e89a98d82c0f4505a3f3d4cd72e7db2eadfbb9.tar.gz
zig-32e89a98d82c0f4505a3f3d4cd72e7db2eadfbb9.zip
Sema: implement union value equality at comptime
Still TODO is extern unions.
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig
index ccf1b37471..68085500bc 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -2934,6 +2934,14 @@ pub const Type = extern union {
};
}
+ /// Asserts the type is a union; returns the tag type, even if the tag will
+ /// not be stored at runtime.
+ pub fn unionTagTypeHypothetical(ty: Type) Type {
+ const union_obj = ty.cast(Payload.Union).?.data;
+ assert(union_obj.haveFieldTypes());
+ return union_obj.tag_ty;
+ }
+
pub fn unionFields(ty: Type) Module.Union.Fields {
const union_obj = ty.cast(Payload.Union).?.data;
assert(union_obj.haveFieldTypes());