aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-20 08:29:14 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-20 08:29:14 -0400
commitdf1300cedea5bc1d942ba214e88b56b5c8b1d45d (patch)
tree3d978628bbb8983706919ca11d321ba0b5e3befe
parentf6246e58a9f437fabff9a90ec46ebda4959ed00b (diff)
Fix issue resolving overloaded procs that contained union parameters
-rw-r--r--src/server/analysis.odin17
-rw-r--r--tests/hover_test.odin34
2 files changed, 49 insertions, 2 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index b7564b1..3f900ff 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -772,8 +772,21 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou
if !ok {
break next_fn
}
-
- if !is_symbol_same_typed(ast_context, call_symbol, arg_symbol, proc_arg.flags) {
+
+ if value, ok := arg_symbol.value.(SymbolUnionValue); ok {
+ found := false
+ for variant in value.types {
+ if symbol, ok := resolve_type_expression(ast_context, variant); ok {
+ if is_symbol_same_typed(ast_context, call_symbol, symbol, proc_arg.flags) {
+ found = true
+ break
+ }
+ }
+ }
+ if !found {
+ break next_fn
+ }
+ } else if !is_symbol_same_typed(ast_context, call_symbol, arg_symbol, proc_arg.flags) {
break next_fn
}
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 65676f1..f29b819 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -2649,6 +2649,40 @@ ast_hover_inside_where_clause :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "test.x: [2]int")
}
+
+@(test)
+ast_hover_overloading_with_union :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ Foo :: struct {
+ foo: int,
+ }
+
+ Bar :: struct {
+ bar: string,
+ }
+
+ FooBar :: union {
+ Foo,
+ Bar,
+ }
+
+ foo_bar :: proc(fb: FooBar) {}
+ bar :: proc(bar: Bar) {}
+
+ my_overload :: proc {
+ foo_bar,
+ bar,
+ }
+
+ main :: proc() {
+ foo: Foo
+ my_overloa{*}d(foo)
+ }
+ `,
+ }
+ test.expect_hover(t, &source, "test.my_overload: proc(fb: FooBar)")
+}
/*
Waiting for odin fix