| ... | ... | @@ -21547,6 +21547,8 @@ fn resolveUnionLayout( |
| 21547 | 21547 | union_obj.status = .have_layout; |
| 21548 | 21548 | } |
| 21549 | 21549 | |
| 21550 | /// Returns `error.AnalysisFail` if any of the types (recursively) failed to |
| 21551 | /// be resolved. |
| 21550 | 21552 | pub fn resolveTypeFully( |
| 21551 | 21553 | sema: *Sema, |
| 21552 | 21554 | block: *Block, |
| ... | ... | @@ -21595,18 +21597,29 @@ fn resolveStructFully( |
| 21595 | 21597 | const resolved_ty = try sema.resolveTypeFields(block, src, ty); |
| 21596 | 21598 | const payload = resolved_ty.castTag(.@"struct") orelse return; |
| 21597 | 21599 | const struct_obj = payload.data; |
| 21600 | |
| 21598 | 21601 | switch (struct_obj.status) { |
| 21599 | 21602 | .none, .have_field_types, .field_types_wip, .layout_wip, .have_layout => {}, |
| 21600 | 21603 | .fully_resolved_wip, .fully_resolved => return, |
| 21601 | 21604 | } |
| 21602 | 21605 | |
| 21603 | | // After we have resolve struct layout we have to go over the fields again to |
| 21604 | | // make sure pointer fields get their child types resolved as well |
| 21605 | | struct_obj.status = .fully_resolved_wip; |
| 21606 | | for (struct_obj.fields.values()) |field| { |
| 21607 | | try sema.resolveTypeFully(block, src, field.ty); |
| 21606 | log.debug("resolveStructFully {*} ('{s}')", .{ |
| 21607 | struct_obj.owner_decl, struct_obj.owner_decl.name, |
| 21608 | }); |
| 21609 | |
| 21610 | { |
| 21611 | // After we have resolve struct layout we have to go over the fields again to |
| 21612 | // make sure pointer fields get their child types resolved as well. |
| 21613 | // See also similar code for unions. |
| 21614 | const prev_status = struct_obj.status; |
| 21615 | errdefer struct_obj.status = prev_status; |
| 21616 | |
| 21617 | struct_obj.status = .fully_resolved_wip; |
| 21618 | for (struct_obj.fields.values()) |field| { |
| 21619 | try sema.resolveTypeFully(block, src, field.ty); |
| 21620 | } |
| 21621 | struct_obj.status = .fully_resolved; |
| 21608 | 21622 | } |
| 21609 | | struct_obj.status = .fully_resolved; |
| 21610 | 21623 | |
| 21611 | 21624 | // And let's not forget comptime-only status. |
| 21612 | 21625 | _ = try sema.typeRequiresComptime(block, src, ty); |
| ... | ... | @@ -21627,12 +21640,19 @@ fn resolveUnionFully( |
| 21627 | 21640 | .fully_resolved_wip, .fully_resolved => return, |
| 21628 | 21641 | } |
| 21629 | 21642 | |
| 21630 | | // Same goes for unions (see comment about structs) |
| 21631 | | union_obj.status = .fully_resolved_wip; |
| 21632 | | for (union_obj.fields.values()) |field| { |
| 21633 | | try sema.resolveTypeFully(block, src, field.ty); |
| 21643 | { |
| 21644 | // After we have resolve union layout we have to go over the fields again to |
| 21645 | // make sure pointer fields get their child types resolved as well. |
| 21646 | // See also similar code for structs. |
| 21647 | const prev_status = union_obj.status; |
| 21648 | errdefer union_obj.status = prev_status; |
| 21649 | |
| 21650 | union_obj.status = .fully_resolved_wip; |
| 21651 | for (union_obj.fields.values()) |field| { |
| 21652 | try sema.resolveTypeFully(block, src, field.ty); |
| 21653 | } |
| 21654 | union_obj.status = .fully_resolved; |
| 21634 | 21655 | } |
| 21635 | | union_obj.status = .fully_resolved; |
| 21636 | 21656 | |
| 21637 | 21657 | // And let's not forget comptime-only status. |
| 21638 | 21658 | _ = try sema.typeRequiresComptime(block, src, ty); |