Fix using on import names

This commit is contained in:
Ginger Bill
2017-10-08 11:08:15 +01:00
parent 56a98a483f
commit 580ee5cc4a
2 changed files with 4 additions and 3 deletions

View File

@@ -482,6 +482,8 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
if (t->kind == Type_Enum) {
for (isize i = 0; i < t->Enum.field_count; i++) {
Entity *f = t->Enum.fields[i];
if (!is_entity_exported(f)) continue;
Entity *found = scope_insert_entity(c->context.scope, f);
if (found != nullptr) {
gbString expr_str = expr_to_string(expr);
@@ -502,6 +504,8 @@ bool check_using_stmt_entity(Checker *c, AstNodeUsingStmt *us, AstNode *expr, bo
Scope *scope = e->ImportName.scope;
for_array(i, scope->elements.entries) {
Entity *decl = scope->elements.entries[i].value;
if (!is_entity_exported(decl)) continue;
Entity *found = scope_insert_entity(c->context.scope, decl);
if (found != nullptr) {
gbString expr_str = expr_to_string(expr);

View File

@@ -2521,9 +2521,6 @@ void check_add_import_decl(Checker *c, AstNodeImportDecl *id) {
Entity *e = scope->elements.entries[elem_index].value;
if (e->scope == parent_scope) return;
if (!is_entity_kind_exported(e->kind)) {
return;
}
if (is_entity_exported(e)) {
// TODO(bill): Should these entities be imported but cause an error when used?
bool ok = add_entity(c, parent_scope, e->identifier, e);