diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-30 09:21:34 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-30 09:21:34 -0400 |
| commit | 97e83b6c825b451c44bdee207e9521bf2cc9c7a5 (patch) | |
| tree | ca57caf0524600398526fd7eb3cd1da151dd22f9 | |
| parent | 5263847aa5cb7ed2e2af029e60af557d82ac605f (diff) | |
| parent | c18e6222d276e119dad36fb5bb49553f187bb662 (diff) | |
Merge pull request #805 from BradLewis/fix/resolve-using-types
Fix issue looking up using package when resolving types
| -rw-r--r-- | src/server/analysis.odin | 2 | ||||
| -rw-r--r-- | tests/hover_test.odin | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index a7b7695..f483a75 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1901,7 +1901,7 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide for u in ast_context.usings { for imp in ast_context.imports { - if strings.compare(imp.base, u.pkg_name) == 0 { + if strings.compare(imp.name, u.pkg_name) == 0 { if symbol, ok := lookup(node.name, imp.name); ok { return resolve_symbol_return(ast_context, symbol) } diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 3c22852..54e3cf2 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -3124,6 +3124,45 @@ ast_hover_switch_initialiser :: proc(t: ^testing.T) { "test.c: test.A :: enum {\n\tB,\n\tC,\n}", ) } + +@(test) +ast_hover_type_switch_with_using :: proc(t: ^testing.T) { + packages := make([dynamic]test.Package, context.temp_allocator) + + append( + &packages, + test.Package { + pkg = "my_package", + source = `package my_package + Foo :: struct{} + Bar :: struct{} + Foo_Bar :: union { + ^Foo, + ^Bar, + } + `, + }, + ) + source := test.Source { + main = `package test + import "my_package" + + foo :: proc(fb: ^my_package.Foo_Bar) { + using my_package + #partial switch v in fb { + case ^Foo: + v{*} + } + } + `, + packages = packages[:], + } + test.expect_hover( + t, + &source, + "test.v: ^my_package.Foo :: struct {}", + ) +} /* Waiting for odin fix |