@@ -3932,11 +3932,12 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,
3932
3932
// Whilst constructing our mapping, we will also initialize optional and error union payloads when
3933
3933
// we encounter the corresponding pointers. For this reason, the ordering of `to_map` matters.
3934
3934
var to_map = try std.ArrayList(Air.Inst.Index).initCapacity(sema.arena, stores.len);
3935
+
3935
3936
for (stores) |store_inst_idx| {
3936
3937
const store_inst = sema.air_instructions.get(@intFromEnum(store_inst_idx));
3937
3938
const ptr_to_map = switch (store_inst.tag) {
3938
3939
.store, .store_safe => store_inst.data.bin_op.lhs.toIndex().?, // Map the pointer being stored to.
3939
- .set_union_tag => continue , // Ignore for now; handled after we map pointers
3940
+ .set_union_tag => store_inst.data.bin_op.lhs.toIndex().? , // Map the union pointer.
3940
3941
.optional_payload_ptr_set, .errunion_payload_ptr_set => store_inst_idx, // Map the generated pointer itself.
3941
3942
else => unreachable,
3942
3943
};
@@ -4053,13 +4054,12 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,
4053
4054
const maybe_union_ty = Value.fromInterned(decl_parent_ptr).typeOf(zcu).childType(zcu);
4054
4055
if (zcu.typeToUnion(maybe_union_ty)) |union_obj| {
4055
4056
// As this is a union field, we must store to the pointer now to set the tag.
4056
- // If the payload is OPV, there will not be a payload store, so we store that value.
4057
- // Otherwise, there will be a payload store to process later, so undef will suffice.
4057
+ // The payload value will be stored later, so undef is a sufficent payload for now.
4058
4058
const payload_ty: Type = .fromInterned(union_obj.field_types.get(&zcu.intern_pool)[idx]);
4059
- const payload_val = try sema.typeHasOnePossibleValue(payload_ty) orelse try pt.undefValue(payload_ty);
4059
+ const payload_val = try pt.undefValue(payload_ty);
4060
4060
const tag_val = try pt.enumValueFieldIndex(.fromInterned(union_obj.enum_tag_ty), idx);
4061
4061
const store_val = try pt.unionValue(maybe_union_ty, tag_val, payload_val);
4062
- try sema.storePtrVal(block, LazySrcLoc .unneeded, Value .fromInterned(decl_parent_ptr), store_val, maybe_union_ty);
4062
+ try sema.storePtrVal(block, .unneeded, .fromInterned(decl_parent_ptr), store_val, maybe_union_ty);
4063
4063
}
4064
4064
break :ptr (try Value.fromInterned(decl_parent_ptr).ptrField(idx, pt)).toIntern();
4065
4065
},
0 commit comments