| ... | ... | @@ -1094,13 +1094,18 @@ pub fn abiSize(ty: Type, zcu: *const Zcu) u64 { |
| 1094 | 1094 | }, |
| 1095 | 1095 | .opt_type => |child_ty_ip| { |
| 1096 | 1096 | const child_ty: Type = .fromInterned(child_ty_ip); |
| 1097 | | if (child_ty.classify(zcu) == .no_possible_value) return 0; |
| 1098 | | if (ty.optionalReprIsPayload(zcu)) return child_ty.abiSize(zcu); |
| 1099 | | // Optional types are represented as a struct with the child type as the first |
| 1100 | | // field and a boolean as the second. Since the child type's abi alignment is |
| 1101 | | // guaranteed to be >= that of bool's (1 byte) the added size is exactly equal |
| 1102 | | // to the child type's ABI alignment. |
| 1103 | | return child_ty.abiSize(zcu) + child_ty.abiAlignment(zcu).toByteUnits().?; |
| 1097 | switch (child_ty.classify(zcu)) { |
| 1098 | .no_possible_value => return 0, // we are OPV |
| 1099 | .fully_comptime => return 0, // we are also fully_comptime (same justification as error unions, see below) |
| 1100 | .one_possible_value, .partially_comptime, .runtime => { |
| 1101 | if (ty.optionalReprIsPayload(zcu)) return child_ty.abiSize(zcu); |
| 1102 | // Optional types are represented as a struct with the child type as the first |
| 1103 | // field and a boolean as the second. Since the child type's abi alignment is |
| 1104 | // guaranteed to be >= that of bool's (1 byte) the added size is exactly equal |
| 1105 | // to the child type's ABI alignment. |
| 1106 | return child_ty.abiSize(zcu) + child_ty.abiAlignment(zcu).toByteUnits().?; |
| 1107 | }, |
| 1108 | } |
| 1104 | 1109 | }, |
| 1105 | 1110 | .error_set_type, .inferred_error_set_type => errorAbiSize(zcu), |
| 1106 | 1111 | .error_union_type => |error_union| { |