From f80b0d2b3d379aa74af88f7502fb4b2d186e13b3 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:54:43 -0500 Subject: Score overload candidates higher if they contain the correct number of args --- src/server/analysis.odin | 3 +++ tests/hover_test.odin | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 4ed56b7..9d93f39 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -734,6 +734,9 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou if call_expr != nil && arg_count < len(call_expr.args) { break next_fn } + if arg_count == len(call_expr.args) { + candidate.score /= 2 + } } for proc_arg in procedure.arg_types { for name in proc_arg.names { diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 657bc9e..5df5ba7 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -5493,6 +5493,28 @@ ast_hover_parapoly_return_dynamic_array :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.foo: [dynamic]string") } + +@(test) +ast_hover_proc_overload_with_less_args :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: struct {} + + foo_out :: proc(input: int, out_struct: ^Foo) -> (ok: bool) {} + foo_helper :: proc(input: int) -> (out_struct: Foo, ok: bool) {} + + foo :: proc { + foo_out, + foo_helper, + } + + main :: proc() { + some, ok := f{*}oo(1) + } + `, + } + test.expect_hover(t, &source, "test.foo :: proc(input: int) -> (out_struct: Foo, ok: bool)") +} /* Waiting for odin fix -- cgit v1.2.3