aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-09-26 11:16:03 +0300
committerGitHub <noreply@github.com>2023-09-26 11:16:03 +0300
commitf4c884617f499b52eaecc0ef674609c774052f8f (patch)
treec24e4628c314d5e815f4b9796d0ff70335fa58a3 /src/Module.zig
parent2adb932ad6ee4ff3d3c640cb8fb7bf7db0ff5d74 (diff)
parent9f4649b197b720dbc168ced25eee0805d3b678b1 (diff)
downloadzig-f4c884617f499b52eaecc0ef674609c774052f8f.tar.gz
zig-f4c884617f499b52eaecc0ef674609c774052f8f.zip
Merge pull request #17215 from kcbanner/read_from_memory_union
sema: add support for unions in readFromMemory and writeToMemory
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 0601a77320..c847fadc17 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -5825,7 +5825,7 @@ pub fn markReferencedDeclsAlive(mod: *Module, val: Value) Allocator.Error!void {
.aggregate => |aggregate| for (aggregate.storage.values()) |elem|
try mod.markReferencedDeclsAlive(elem.toValue()),
.un => |un| {
- try mod.markReferencedDeclsAlive(un.tag.toValue());
+ if (un.tag != .none) try mod.markReferencedDeclsAlive(un.tag.toValue());
try mod.markReferencedDeclsAlive(un.val.toValue());
},
else => {},
@@ -6609,6 +6609,7 @@ pub fn unionFieldNormalAlignment(mod: *Module, u: InternPool.UnionType, field_in
pub fn unionTagFieldIndex(mod: *Module, u: InternPool.UnionType, enum_tag: Value) ?u32 {
const ip = &mod.intern_pool;
+ if (enum_tag.toIntern() == .none) return null;
assert(ip.typeOf(enum_tag.toIntern()) == u.enum_tag_ty);
const enum_type = ip.indexToKey(u.enum_tag_ty).enum_type;
return enum_type.tagValueIndex(ip, enum_tag.toIntern());