diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-14 12:25:30 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-14 12:27:29 -0400 |
| commit | 5e55397d6b64e7c6da29c2db384cf240008927c4 (patch) | |
| tree | c4d8f773298ccb3f76e2b7779c5a4abf8c49fb60 /src/server | |
| parent | a4534a5d35f461ef6df6ee77edfa8cdcff2886f2 (diff) | |
Fix resolution of identifiers from other packages that share the same name as a local variable
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/analysis.odin | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 9311328..d7dae90 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1165,12 +1165,18 @@ get_local :: proc(ast_context: AstContext, ident: ast.Ident) -> (DocumentLocal, local_stack := locals[ident.name] or_continue #reverse for local in local_stack { + // Ensure that if the identifier has a file, the local is also part of the same file + // and the context is in the correct package + correct_file := ident.pos.file == "" || local.lhs.pos.file == ident.pos.file + correct_package := ast_context.current_package == ast_context.document_package + if !correct_file || !correct_package { + continue + } + if local.local_global { return local, true } - // Ensure that if the identifier has a file, the local is also part of the same file - correct_file := ident.pos.file == "" || local.lhs.pos.file == ident.pos.file - if correct_file && (local.offset <= ident.pos.offset || local.lhs.pos.offset == ident.pos.offset) { + if local.offset <= ident.pos.offset || local.lhs.pos.offset == ident.pos.offset { // checking equal offsets is a hack to allow matching lhs ident in var decls // because otherwise minimal offset begins after the decl return local, true @@ -2811,7 +2817,6 @@ get_generic_assignment :: proc( //We have to resolve early and can't rely on lazy evalutation because it can have multiple returns. if symbol, ok := resolve_type_expression(ast_context, v.expr); ok { - #partial switch symbol_value in symbol.value { case SymbolProcedureValue: for ret in symbol_value.return_types { |