diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-10-11 04:44:43 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-10-11 04:44:43 -0400 |
| commit | a2b472d5fd8169de682e144b5dc76c99a24fe96c (patch) | |
| tree | 937cc16ae95862cec74a568d9cfcc9a01d0d655a | |
| parent | 3e6c49805a003e224b709bfa15d42f3f1081db11 (diff) | |
Improve proc group resolution with named args
| -rw-r--r-- | src/server/analysis.odin | 2 | ||||
| -rw-r--r-- | tests/hover_test.odin | 48 |
2 files changed, 49 insertions, 1 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 8bc311a..ff94e41 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -729,7 +729,7 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou if !resolve_all_possibilities { arg_count := get_proc_arg_count(procedure) - if call_expr != nil && arg_count < call_unnamed_arg_count { + if call_expr != nil && arg_count < len(call_expr.args) { break next_fn } } diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 6461621..a90346e 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5234,6 +5234,54 @@ ast_hover_proc_group_with_enum_arg :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.bar :: proc(foo: Foo)") } + +@(test) +ast_hover_proc_group_with_enum_named_arg :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: enum { + A, + B, + C, + } + + bar_none :: proc() {} + bar_foo :: proc(i: int, foo: Foo) {} + bar :: proc { + bar_none, + bar_foo, + } + + main :: proc() { + b{*}ar(foo = .B, i = 2) + } + + `, + } + test.expect_hover(t, &source, "test.bar :: proc(i: int, foo: Foo)") +} + +@(test) +ast_hover_proc_group_named_arg_with_nil :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: struct {} + + bar_none :: proc() {} + bar_foo :: proc(i: int, foo: ^Foo) {} + bar :: proc { + bar_none, + bar_foo, + } + + main :: proc() { + b{*}ar(foo = nil, i = 2) + } + + `, + } + test.expect_hover(t, &source, "test.bar :: proc(i: int, foo: ^Foo)") +} /* Waiting for odin fix |