| ... | @@ -2459,6 +2459,7 @@ pub const Type = extern union { | ... | @@ -2459,6 +2459,7 @@ pub const Type = extern union { |
| 2459 | if (struct_obj.status == .field_types_wip) { | 2459 | if (struct_obj.status == .field_types_wip) { |
| 2460 | // In this case, we guess that hasRuntimeBits() for this type is true, | 2460 | // In this case, we guess that hasRuntimeBits() for this type is true, |
| 2461 | // and then later if our guess was incorrect, we emit a compile error. | 2461 | // and then later if our guess was incorrect, we emit a compile error. |
| | 2462 | struct_obj.assumed_runtime_bits = true; |
| 2462 | return true; | 2463 | return true; |
| 2463 | } | 2464 | } |
| 2464 | switch (strat) { | 2465 | switch (strat) { |
| ... | @@ -2491,6 +2492,12 @@ pub const Type = extern union { | ... | @@ -2491,6 +2492,12 @@ pub const Type = extern union { |
| 2491 | | 2492 | |
| 2492 | .@"union" => { | 2493 | .@"union" => { |
| 2493 | const union_obj = ty.castTag(.@"union").?.data; | 2494 | const union_obj = ty.castTag(.@"union").?.data; |
| | 2495 | if (union_obj.status == .field_types_wip) { |
| | 2496 | // In this case, we guess that hasRuntimeBits() for this type is true, |
| | 2497 | // and then later if our guess was incorrect, we emit a compile error. |
| | 2498 | union_obj.assumed_runtime_bits = true; |
| | 2499 | return true; |
| | 2500 | } |
| 2494 | switch (strat) { | 2501 | switch (strat) { |
| 2495 | .sema => |sema| _ = try sema.resolveTypeFields(ty), | 2502 | .sema => |sema| _ = try sema.resolveTypeFields(ty), |
| 2496 | .eager => assert(union_obj.haveFieldTypes()), | 2503 | .eager => assert(union_obj.haveFieldTypes()), |
| ... | @@ -3027,8 +3034,9 @@ pub const Type = extern union { | ... | @@ -3027,8 +3034,9 @@ pub const Type = extern union { |
| 3027 | const struct_obj = ty.castTag(.@"struct").?.data; | 3034 | const struct_obj = ty.castTag(.@"struct").?.data; |
| 3028 | if (opt_sema) |sema| { | 3035 | if (opt_sema) |sema| { |
| 3029 | if (struct_obj.status == .field_types_wip) { | 3036 | if (struct_obj.status == .field_types_wip) { |
| 3030 | // We'll guess "pointer-aligned" and if we guess wrong, emit | 3037 | // We'll guess "pointer-aligned", if the struct has an |
| 3031 | // a compile error later. | 3038 | // underaligned pointer field then some allocations |
| | 3039 | // might require explicit alignment. |
| 3032 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }; | 3040 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }; |
| 3033 | } | 3041 | } |
| 3034 | _ = try sema.resolveTypeFields(ty); | 3042 | _ = try sema.resolveTypeFields(ty); |
| ... | @@ -3153,8 +3161,9 @@ pub const Type = extern union { | ... | @@ -3153,8 +3161,9 @@ pub const Type = extern union { |
| 3153 | }; | 3161 | }; |
| 3154 | if (opt_sema) |sema| { | 3162 | if (opt_sema) |sema| { |
| 3155 | if (union_obj.status == .field_types_wip) { | 3163 | if (union_obj.status == .field_types_wip) { |
| 3156 | // We'll guess "pointer-aligned" and if we guess wrong, emit | 3164 | // We'll guess "pointer-aligned", if the union has an |
| 3157 | // a compile error later. | 3165 | // underaligned pointer field then some allocations |
| | 3166 | // might require explicit alignment. |
| 3158 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }; | 3167 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }; |
| 3159 | } | 3168 | } |
| 3160 | _ = try sema.resolveTypeFields(ty); | 3169 | _ = try sema.resolveTypeFields(ty); |
| ... | @@ -5234,7 +5243,12 @@ pub const Type = extern union { | ... | @@ -5234,7 +5243,12 @@ pub const Type = extern union { |
| 5234 | .@"struct" => { | 5243 | .@"struct" => { |
| 5235 | const struct_obj = ty.castTag(.@"struct").?.data; | 5244 | const struct_obj = ty.castTag(.@"struct").?.data; |
| 5236 | switch (struct_obj.requires_comptime) { | 5245 | switch (struct_obj.requires_comptime) { |
| 5237 | .wip, .unknown => unreachable, // This function asserts types already resolved. | 5246 | .wip, .unknown => { |
| | 5247 | // Return false to avoid incorrect dependency loops. |
| | 5248 | // This will be handled correctly once merged with |
| | 5249 | // `Sema.typeRequiresComptime`. |
| | 5250 | return false; |
| | 5251 | }, |
| 5238 | .no => return false, | 5252 | .no => return false, |
| 5239 | .yes => return true, | 5253 | .yes => return true, |
| 5240 | } | 5254 | } |
| ... | @@ -5243,7 +5257,12 @@ pub const Type = extern union { | ... | @@ -5243,7 +5257,12 @@ pub const Type = extern union { |
| 5243 | .@"union", .union_safety_tagged, .union_tagged => { | 5257 | .@"union", .union_safety_tagged, .union_tagged => { |
| 5244 | const union_obj = ty.cast(Type.Payload.Union).?.data; | 5258 | const union_obj = ty.cast(Type.Payload.Union).?.data; |
| 5245 | switch (union_obj.requires_comptime) { | 5259 | switch (union_obj.requires_comptime) { |
| 5246 | .wip, .unknown => unreachable, // This function asserts types already resolved. | 5260 | .wip, .unknown => { |
| | 5261 | // Return false to avoid incorrect dependency loops. |
| | 5262 | // This will be handled correctly once merged with |
| | 5263 | // `Sema.typeRequiresComptime`. |
| | 5264 | return false; |
| | 5265 | }, |
| 5247 | .no => return false, | 5266 | .no => return false, |
| 5248 | .yes => return true, | 5267 | .yes => return true, |
| 5249 | } | 5268 | } |