From b5587f1937edf8440fdf713988c9e3bc38886e93 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Tue, 11 Jul 2017 20:54:38 +0100 Subject: [PATCH] Fix aliasing of overloaded procedures from other scopes --- core/_preload.odin | 11 +++++------ src/check_expr.cpp | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/core/_preload.odin b/core/_preload.odin index 0d6d0b74c..9d012de0d 100644 --- a/core/_preload.odin +++ b/core/_preload.odin @@ -159,8 +159,7 @@ Allocator :: struct #ordered { Context :: struct #ordered { - thread_guid: int; - thread_index: int; + thread_id: int; allocator: Allocator; @@ -256,8 +255,8 @@ __init_context_from_ptr :: proc(c: ^Context, other: ^Context) #cc_contextless { if c.allocator.procedure == nil { c.allocator = default_allocator(); } - if c.thread_guid == 0 { - c.thread_guid = os.current_thread_id(); + if c.thread_id == 0 { + c.thread_id = os.current_thread_id(); } } @@ -267,8 +266,8 @@ __init_context :: proc(c: ^Context) #cc_contextless { if c.allocator.procedure == nil { c.allocator = default_allocator(); } - if c.thread_guid == 0 { - c.thread_guid = os.current_thread_id(); + if c.thread_id == 0 { + c.thread_id = os.current_thread_id(); } } diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 215299f96..ba182db3f 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -4081,6 +4081,13 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h String op_name = op_expr->Ident.token.string; Entity *e = scope_lookup_entity(c->context.scope, op_name); + bool is_alias = false; + while (e->kind == Entity_Alias) { + GB_ASSERT(e->Alias.base != nullptr); + e = e->Alias.base; + is_alias = true; + } + add_entity_use(c, op_expr, e); expr_entity = e; @@ -4111,9 +4118,24 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h operand->expr = node; return nullptr; } + + + bool is_alias = false; + while (entity->kind == Entity_Alias) { + GB_ASSERT(e->Alias.base != nullptr); + entity = entity->Alias.base; + is_alias = true; + } + check_entity_decl(c, entity, nullptr, nullptr); GB_ASSERT(entity->type != nullptr); + if (is_alias) { + // TODO(bill): Which scope do you search for for an alias? + // import_scope = entity->scope; + entity_name = entity->token.string; + } + isize overload_count = entity_overload_count(import_scope, entity_name); bool is_overloaded = overload_count > 1;