| ... | @@ -48,6 +48,8 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa | ... | @@ -48,6 +48,8 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa |
| 48 | bool expr_is_maybe, AstNode *decl_node, bool var_is_ptr); | 48 | bool expr_is_maybe, AstNode *decl_node, bool var_is_ptr); |
| 49 | static void scan_decls(CodeGen *g, ImportTableEntry *import, BlockContext *context, AstNode *node); | 49 | static void scan_decls(CodeGen *g, ImportTableEntry *import, BlockContext *context, AstNode *node); |
| 50 | static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry); | 50 | static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry); |
| | 51 | static void resolve_use_decl(CodeGen *g, AstNode *node); |
| | 52 | static void preview_use_decl(CodeGen *g, AstNode *node); |
| 51 | | 53 | |
| 52 | static AstNode *first_executing_node(AstNode *node) { | 54 | static AstNode *first_executing_node(AstNode *node) { |
| 53 | switch (node->type) { | 55 | switch (node->type) { |
| ... | @@ -2692,6 +2694,17 @@ static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *i | ... | @@ -2692,6 +2694,17 @@ static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *i |
| 2692 | assert(const_val->ok); | 2694 | assert(const_val->ok); |
| 2693 | ImportTableEntry *namespace_import = const_val->data.x_import; | 2695 | ImportTableEntry *namespace_import = const_val->data.x_import; |
| 2694 | AstNode *decl_node = find_decl(namespace_import->block_context, field_name); | 2696 | AstNode *decl_node = find_decl(namespace_import->block_context, field_name); |
| | 2697 | if (!decl_node) { |
| | 2698 | // we must now resolve all the use decls |
| | 2699 | for (int i = 0; i < namespace_import->use_decls.length; i += 1) { |
| | 2700 | AstNode *use_decl_node = namespace_import->use_decls.at(i); |
| | 2701 | if (!get_resolved_expr(use_decl_node->data.use.expr)->type_entry) { |
| | 2702 | preview_use_decl(g, use_decl_node); |
| | 2703 | } |
| | 2704 | resolve_use_decl(g, use_decl_node); |
| | 2705 | } |
| | 2706 | decl_node = find_decl(namespace_import->block_context, field_name); |
| | 2707 | } |
| 2695 | if (decl_node) { | 2708 | if (decl_node) { |
| 2696 | TopLevelDecl *tld = get_as_top_level_decl(decl_node); | 2709 | TopLevelDecl *tld = get_as_top_level_decl(decl_node); |
| 2697 | if (tld->visib_mod == VisibModPrivate) { | 2710 | if (tld->visib_mod == VisibModPrivate) { |
| ... | @@ -6522,6 +6535,8 @@ static void add_symbols_from_import(CodeGen *g, AstNode *src_use_node, AstNode * | ... | @@ -6522,6 +6535,8 @@ static void add_symbols_from_import(CodeGen *g, AstNode *src_use_node, AstNode * |
| 6522 | return; | 6535 | return; |
| 6523 | } | 6536 | } |
| 6524 | | 6537 | |
| | 6538 | tld->resolution = TldResolutionOk; |
| | 6539 | |
| 6525 | ConstExprValue *const_val = &expr->const_val; | 6540 | ConstExprValue *const_val = &expr->const_val; |
| 6526 | assert(const_val->ok); | 6541 | assert(const_val->ok); |
| 6527 | | 6542 | |
| ... | @@ -6570,6 +6585,9 @@ static void add_symbols_from_import(CodeGen *g, AstNode *src_use_node, AstNode * | ... | @@ -6570,6 +6585,9 @@ static void add_symbols_from_import(CodeGen *g, AstNode *src_use_node, AstNode * |
| 6570 | | 6585 | |
| 6571 | static void resolve_use_decl(CodeGen *g, AstNode *node) { | 6586 | static void resolve_use_decl(CodeGen *g, AstNode *node) { |
| 6572 | assert(node->type == NodeTypeUse); | 6587 | assert(node->type == NodeTypeUse); |
| | 6588 | if (get_as_top_level_decl(node)->resolution != TldResolutionUnresolved) { |
| | 6589 | return; |
| | 6590 | } |
| 6573 | add_symbols_from_import(g, node, node); | 6591 | add_symbols_from_import(g, node, node); |
| 6574 | } | 6592 | } |
| 6575 | | 6593 | |