| ... | @@ -3779,6 +3779,7 @@ fn validateStructInit( | ... | @@ -3779,6 +3779,7 @@ fn validateStructInit( |
| 3779 | if ((is_comptime or block.is_comptime) and | 3779 | if ((is_comptime or block.is_comptime) and |
| 3780 | (try sema.resolveDefinedValue(block, init_src, struct_ptr)) != null) | 3780 | (try sema.resolveDefinedValue(block, init_src, struct_ptr)) != null) |
| 3781 | { | 3781 | { |
| | 3782 | try sema.resolveStructLayout(block, init_src, struct_ty); |
| 3782 | // In this case the only thing we need to do is evaluate the implicit | 3783 | // In this case the only thing we need to do is evaluate the implicit |
| 3783 | // store instructions for default field values, and report any missing fields. | 3784 | // store instructions for default field values, and report any missing fields. |
| 3784 | // Avoid the cost of the extra machinery for detecting a comptime struct init value. | 3785 | // Avoid the cost of the extra machinery for detecting a comptime struct init value. |
| ... | @@ -3973,6 +3974,7 @@ fn validateStructInit( | ... | @@ -3973,6 +3974,7 @@ fn validateStructInit( |
| 3973 | try sema.storePtr2(block, init_src, struct_ptr, init_src, struct_init, init_src, .store); | 3974 | try sema.storePtr2(block, init_src, struct_ptr, init_src, struct_init, init_src, .store); |
| 3974 | return; | 3975 | return; |
| 3975 | } | 3976 | } |
| | 3977 | try sema.resolveStructLayout(block, init_src, struct_ty); |
| 3976 | | 3978 | |
| 3977 | // Our task is to insert `store` instructions for all the default field values. | 3979 | // Our task is to insert `store` instructions for all the default field values. |
| 3978 | for (found_fields) |field_ptr, i| { | 3980 | for (found_fields) |field_ptr, i| { |
| ... | @@ -15843,6 +15845,7 @@ fn finishStructInit( | ... | @@ -15843,6 +15845,7 @@ fn finishStructInit( |
| 15843 | } | 15845 | } |
| 15844 | | 15846 | |
| 15845 | if (is_ref) { | 15847 | if (is_ref) { |
| | 15848 | try sema.resolveStructLayout(block, dest_src, struct_ty); |
| 15846 | const target = sema.mod.getTarget(); | 15849 | const target = sema.mod.getTarget(); |
| 15847 | const alloc_ty = try Type.ptr(sema.arena, sema.mod, .{ | 15850 | const alloc_ty = try Type.ptr(sema.arena, sema.mod, .{ |
| 15848 | .pointee_type = struct_ty, | 15851 | .pointee_type = struct_ty, |
| ... | @@ -28850,7 +28853,7 @@ pub fn typeHasOnePossibleValue( | ... | @@ -28850,7 +28853,7 @@ pub fn typeHasOnePossibleValue( |
| 28850 | for (tuple.values) |val, i| { | 28853 | for (tuple.values) |val, i| { |
| 28851 | const is_comptime = val.tag() != .unreachable_value; | 28854 | const is_comptime = val.tag() != .unreachable_value; |
| 28852 | if (is_comptime) continue; | 28855 | if (is_comptime) continue; |
| 28853 | if ((try sema.typeHasOnePossibleValue(block, src, tuple.types[i])) != null) continue; | 28856 | if ((try sema.typeHasOnePossibleValue(block, src, tuple.types[i])) != null) continue; |
| 28854 | return null; | 28857 | return null; |
| 28855 | } | 28858 | } |
| 28856 | return Value.initTag(.empty_struct_value); | 28859 | return Value.initTag(.empty_struct_value); |