| ... | ... | @@ -3453,11 +3453,12 @@ TypeEnumField *find_enum_field_by_tag(ZigType *enum_type, const BigInt *tag) { |
| 3453 | 3453 | } |
| 3454 | 3454 | |
| 3455 | 3455 | |
| 3456 | | static bool is_container(ZigType *type_entry) { |
| 3456 | bool is_container(ZigType *type_entry) { |
| 3457 | 3457 | switch (type_entry->id) { |
| 3458 | 3458 | case ZigTypeIdInvalid: |
| 3459 | 3459 | zig_unreachable(); |
| 3460 | 3460 | case ZigTypeIdStruct: |
| 3461 | return !type_entry->data.structure.is_slice; |
| 3461 | 3462 | case ZigTypeIdEnum: |
| 3462 | 3463 | case ZigTypeIdUnion: |
| 3463 | 3464 | return true; |
| ... | ... | @@ -3498,9 +3499,9 @@ bool is_array_ref(ZigType *type_entry) { |
| 3498 | 3499 | return array->id == ZigTypeIdArray; |
| 3499 | 3500 | } |
| 3500 | 3501 | |
| 3501 | | bool is_container_ref(ZigType *type_entry) { |
| 3502 | | return is_ref(type_entry) ? |
| 3503 | | is_container(type_entry->data.pointer.child_type) : is_container(type_entry); |
| 3502 | bool is_container_ref(ZigType *parent_ty) { |
| 3503 | ZigType *ty = is_ref(parent_ty) ? parent_ty->data.pointer.child_type : parent_ty; |
| 3504 | return is_slice(ty) || is_container(ty); |
| 3504 | 3505 | } |
| 3505 | 3506 | |
| 3506 | 3507 | ZigType *container_ref_type(ZigType *type_entry) { |
| ... | ... | @@ -3765,7 +3766,7 @@ static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) { |
| 3765 | 3766 | analyze_fn_ir(g, fn_table_entry, return_type_node); |
| 3766 | 3767 | } |
| 3767 | 3768 | |
| 3768 | | static void add_symbols_from_struct(CodeGen *g, AstNode *src_use_node, AstNode *dst_use_node, ScopeDecls* decls_scope) { |
| 3769 | static void add_symbols_from_container(CodeGen *g, AstNode *src_use_node, AstNode *dst_use_node, ScopeDecls* decls_scope) { |
| 3769 | 3770 | if (src_use_node->data.use.resolution == TldResolutionUnresolved) { |
| 3770 | 3771 | preview_use_decl(g, src_use_node, decls_scope); |
| 3771 | 3772 | } |
| ... | ... | @@ -3784,9 +3785,9 @@ static void add_symbols_from_struct(CodeGen *g, AstNode *src_use_node, AstNode * |
| 3784 | 3785 | ZigType *src_ty = use_expr->data.x_type; |
| 3785 | 3786 | assert(src_ty); |
| 3786 | 3787 | |
| 3787 | | if (src_ty->id != ZigTypeIdStruct || is_slice(src_ty)) { |
| 3788 | if (!is_container(src_ty)) { |
| 3788 | 3789 | add_node_error(g, dst_use_node, |
| 3789 | | buf_sprintf("expected struct, found '%s'", buf_ptr(&src_ty->name))); |
| 3790 | buf_sprintf("expected struct, enum, or union; found '%s'", buf_ptr(&src_ty->name))); |
| 3790 | 3791 | decls_scope->any_imports_failed = true; |
| 3791 | 3792 | return; |
| 3792 | 3793 | } |
| ... | ... | @@ -3795,8 +3796,8 @@ static void add_symbols_from_struct(CodeGen *g, AstNode *src_use_node, AstNode * |
| 3795 | 3796 | ScopeDecls *src_scope = get_container_scope(src_ty); |
| 3796 | 3797 | // The top-level container where the symbols are defined, it's used in the |
| 3797 | 3798 | // loop below in order to exclude the ones coming from an import statement |
| 3798 | | ZigType *src_import = get_scope_import(reinterpret_cast<Scope*>(src_scope)); |
| 3799 | | assert(src_import && src_import->id == ZigTypeIdStruct); |
| 3799 | ZigType *src_import = get_scope_import(&src_scope->base); |
| 3800 | assert(src_import != nullptr); |
| 3800 | 3801 | |
| 3801 | 3802 | if (src_scope->any_imports_failed) { |
| 3802 | 3803 | decls_scope->any_imports_failed = true; |
| ... | ... | @@ -3835,7 +3836,7 @@ static void add_symbols_from_struct(CodeGen *g, AstNode *src_use_node, AstNode * |
| 3835 | 3836 | for (size_t i = 0; i < src_scope->use_decls.length; i += 1) { |
| 3836 | 3837 | AstNode *use_decl_node = src_scope->use_decls.at(i); |
| 3837 | 3838 | if (use_decl_node->data.use.visib_mod != VisibModPrivate) |
| 3838 | | add_symbols_from_struct(g, use_decl_node, dst_use_node, decls_scope); |
| 3839 | add_symbols_from_container(g, use_decl_node, dst_use_node, decls_scope); |
| 3839 | 3840 | } |
| 3840 | 3841 | } |
| 3841 | 3842 | |
| ... | ... | @@ -3847,7 +3848,7 @@ void resolve_use_decl(CodeGen *g, AstNode *node, ScopeDecls *decls_scope) { |
| 3847 | 3848 | { |
| 3848 | 3849 | return; |
| 3849 | 3850 | } |
| 3850 | | add_symbols_from_struct(g, node, node, decls_scope); |
| 3851 | add_symbols_from_container(g, node, node, decls_scope); |
| 3851 | 3852 | } |
| 3852 | 3853 | |
| 3853 | 3854 | void preview_use_decl(CodeGen *g, AstNode *node, ScopeDecls *decls_scope) { |