| ... | ... | @@ -3372,10 +3372,14 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue { |
| 3372 | 3372 | }, |
| 3373 | 3373 | .un => |un| { |
| 3374 | 3374 | // in this case we have a packed union which will not be passed by reference. |
| 3375 | | const union_obj = mod.typeToUnion(ty).?; |
| 3376 | | const field_index = mod.unionTagFieldIndex(union_obj, un.tag.toValue()).?; |
| 3377 | | const field_ty = union_obj.field_types.get(ip)[field_index].toType(); |
| 3378 | | return func.lowerConstant(un.val.toValue(), field_ty); |
| 3375 | const constant_ty = if (un.tag == .none) |
| 3376 | try ty.unionBackingType(mod) |
| 3377 | else field_ty: { |
| 3378 | const union_obj = mod.typeToUnion(ty).?; |
| 3379 | const field_index = mod.unionTagFieldIndex(union_obj, un.tag.toValue()).?; |
| 3380 | break :field_ty union_obj.field_types.get(ip)[field_index].toType(); |
| 3381 | }; |
| 3382 | return func.lowerConstant(un.val.toValue(), constant_ty); |
| 3379 | 3383 | }, |
| 3380 | 3384 | .memoized_call => unreachable, |
| 3381 | 3385 | } |