| ... | @@ -9963,6 +9963,26 @@ fn zirSwitchCapture( | ... | @@ -9963,6 +9963,26 @@ fn zirSwitchCapture( |
| 9963 | const field_index = @intCast(u32, operand_ty.unionTagFieldIndex(item_val, sema.mod).?); | 9963 | const field_index = @intCast(u32, operand_ty.unionTagFieldIndex(item_val, sema.mod).?); |
| 9964 | const union_obj = operand_ty.cast(Type.Payload.Union).?.data; | 9964 | const union_obj = operand_ty.cast(Type.Payload.Union).?.data; |
| 9965 | const field_ty = union_obj.fields.values()[field_index].ty; | 9965 | const field_ty = union_obj.fields.values()[field_index].ty; |
| | 9966 | if (try sema.resolveDefinedValue(block, sema.src, operand_ptr)) |union_val| { |
| | 9967 | if (is_ref) { |
| | 9968 | const ptr_field_ty = try Type.ptr(sema.arena, sema.mod, .{ |
| | 9969 | .pointee_type = field_ty, |
| | 9970 | .mutable = operand_ptr_ty.ptrIsMutable(), |
| | 9971 | .@"volatile" = operand_ptr_ty.isVolatilePtr(), |
| | 9972 | .@"addrspace" = operand_ptr_ty.ptrAddressSpace(), |
| | 9973 | }); |
| | 9974 | return sema.addConstant( |
| | 9975 | ptr_field_ty, |
| | 9976 | try Value.Tag.field_ptr.create(sema.arena, .{ |
| | 9977 | .container_ptr = union_val, |
| | 9978 | .container_ty = operand_ty, |
| | 9979 | .field_index = field_index, |
| | 9980 | }), |
| | 9981 | ); |
| | 9982 | } |
| | 9983 | const tag_and_val = union_val.castTag(.@"union").?.data; |
| | 9984 | return sema.addConstant(field_ty, tag_and_val.val); |
| | 9985 | } |
| 9966 | if (is_ref) { | 9986 | if (is_ref) { |
| 9967 | const ptr_field_ty = try Type.ptr(sema.arena, sema.mod, .{ | 9987 | const ptr_field_ty = try Type.ptr(sema.arena, sema.mod, .{ |
| 9968 | .pointee_type = field_ty, | 9988 | .pointee_type = field_ty, |