aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-10-03 23:34:20 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-10-03 23:34:20 +0200
commit57a37215651cc18f75bd7421787fa34f8d7278e2 (patch)
tree10f0e424e035af4cdec5a89381e2ac49ab64da15 /src
parentd6fd27fd0f73ef41193b3a1d3751ba756d199cb1 (diff)
Fix issues with package name and variable name clash
Diffstat (limited to 'src')
-rw-r--r--src/server/analysis.odin36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index b27f6b7..59354b7 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1172,20 +1172,6 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide
}
}
- for imp in ast_context.imports {
- if strings.compare(imp.base, node.name) == 0 {
- symbol := Symbol {
- type = .Package,
- pkg = imp.name,
- value = SymbolPackageValue{},
- }
-
- try_build_package(symbol.pkg)
-
- return symbol, true
- }
- }
-
if local, ok := get_local(ast_context^, node); ok && ast_context.use_locals {
is_distinct := false
@@ -1284,7 +1270,27 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide
return return_symbol, ok
- } else if global, ok := ast_context.globals[node.name];
+ }
+
+ for imp in ast_context.imports {
+ if imp.name == ast_context.current_package {
+ continue
+ }
+
+ if strings.compare(imp.base, node.name) == 0 {
+ symbol := Symbol {
+ type = .Package,
+ pkg = imp.name,
+ value = SymbolPackageValue{},
+ }
+
+ try_build_package(symbol.pkg)
+
+ return symbol, true
+ }
+ }
+
+ if global, ok := ast_context.globals[node.name];
ast_context.current_package == ast_context.document_package && ok {
is_distinct := false
ast_context.use_locals = false