diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-10-12 20:28:32 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-10-12 20:28:32 +0100 |
| commit | bbb0e14633716552b8533071cdc1ab9dab91312e (patch) | |
| tree | 612deb806abb61d9bf8260562fcc79d909b5537f /src/check_expr.cpp | |
| parent | 42312d9def0d7d99e124e95645d8cfdaaf1e1ee8 (diff) | |
Fix `using import` to work correctly
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 43a6098b8..30b6928ef 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2540,18 +2540,10 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h bool is_not_exported = !is_entity_exported(entity); if (entity->kind == Entity_ImportName) { is_not_exported = true; - } else if (!implicit_is_found) { - is_not_exported = false; + } else if (implicit_is_found) { + is_not_exported = !is_overloaded; } - if (is_not_exported) { - gbString sel_str = expr_to_string(selector); - error(op_expr, "`%s` is not exported by `%.*s`", sel_str, LIT(import_name)); - gb_string_free(sel_str); - operand->mode = Addressing_Invalid; - operand->expr = node; - return nullptr; - } if (is_overloaded) { HashKey key = hash_string(entity_name); @@ -2567,7 +2559,7 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h } // NOTE(bill): Check to see if it's imported - if (map_get(&import_scope->implicit, hash_entity(procs[i]))) { + if (is_entity_implicitly_imported(e, procs[i])) { gb_swap(Entity *, procs[i], procs[overload_count-1]); overload_count--; i--; // NOTE(bill): Counteract the post event @@ -2586,15 +2578,28 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h } } - if (overload_count > 0 && !skip) { - operand->mode = Addressing_Overload; - operand->type = t_invalid; - operand->expr = node; - operand->overload_count = overload_count; - operand->overload_entities = procs; - return procs[0]; + if (!skip) { + if (overload_count > 0) { + operand->mode = Addressing_Overload; + operand->type = t_invalid; + operand->expr = node; + operand->overload_count = overload_count; + operand->overload_entities = procs; + return procs[0]; + } else { + is_not_exported = true; + } } } + + if (is_not_exported) { + gbString sel_str = expr_to_string(selector); + error(op_expr, "`%s` is not exported by `%.*s`", sel_str, LIT(import_name)); + gb_string_free(sel_str); + operand->mode = Addressing_Invalid; + operand->expr = node; + return nullptr; + } } } |