aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-05-19 23:16:36 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:53 -0700
commitc4735941148eb32eee16307ba13876ae21606fba (patch)
tree19d2bb586c02ba132c85965fbbf1dc2cdf3ddc15 /src/type.zig
parentf8b6eb63d53bba303a200a5c2493c5d5bddd1f66 (diff)
downloadzig-c4735941148eb32eee16307ba13876ae21606fba.tar.gz
zig-c4735941148eb32eee16307ba13876ae21606fba.zip
Sema: port reify struct access to use InternPool
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/type.zig b/src/type.zig
index 019557c5e0..d0cf054845 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -3148,8 +3148,13 @@ pub const Type = struct {
pub fn enumTagFieldIndex(ty: Type, enum_tag: Value, mod: *Module) ?u32 {
const ip = &mod.intern_pool;
const enum_type = ip.indexToKey(ty.ip_index).enum_type;
- assert(ip.typeOf(enum_tag.ip_index) == enum_type.tag_ty);
- return enum_type.tagValueIndex(ip, enum_tag.ip_index);
+ const int_tag = switch (ip.indexToKey(enum_tag.ip_index)) {
+ .int => enum_tag.ip_index,
+ .enum_tag => |info| info.int,
+ else => unreachable,
+ };
+ assert(ip.typeOf(int_tag) == enum_type.tag_ty);
+ return enum_type.tagValueIndex(ip, int_tag);
}
pub fn structFields(ty: Type, mod: *Module) Module.Struct.Fields {