From f6335de738e47dff08ab4fefc8aad027f860076b Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Tue, 10 Jun 2025 12:36:29 -0400 Subject: Ensure for locals that they are defined in the same file as the identifier --- src/server/analysis.odin | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 668260b..1988353 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1111,7 +1111,12 @@ get_local :: proc(ast_context: AstContext, ident: ast.Ident) -> (DocumentLocal, local_stack := locals[ident.name] or_continue #reverse for local in local_stack { - if local.offset <= ident.pos.offset || local.local_global || local.lhs.pos.offset == ident.pos.offset { + 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) { // 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 -- cgit v1.2.3