Commit 1acb6a53d0
Changed files (1)
src
arch
wasm
src/arch/wasm/CodeGen.zig
@@ -3372,10 +3372,14 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
},
.un => |un| {
// in this case we have a packed union which will not be passed by reference.
- const union_obj = mod.typeToUnion(ty).?;
- const field_index = mod.unionTagFieldIndex(union_obj, un.tag.toValue()).?;
- const field_ty = union_obj.field_types.get(ip)[field_index].toType();
- return func.lowerConstant(un.val.toValue(), field_ty);
+ const constant_ty = if (un.tag == .none)
+ try ty.unionBackingType(mod)
+ else field_ty: {
+ const union_obj = mod.typeToUnion(ty).?;
+ const field_index = mod.unionTagFieldIndex(union_obj, un.tag.toValue()).?;
+ break :field_ty union_obj.field_types.get(ip)[field_index].toType();
+ };
+ return func.lowerConstant(un.val.toValue(), constant_ty);
},
.memoized_call => unreachable,
}