From 706179fb745803ff805f959cae8e87586a4c0e2c Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Fri, 31 Oct 2025 14:08:20 -0300 Subject: [PATCH] checker: fix generic resolve for external module generic static method call (fix #21476) (#25634) --- vlib/v/checker/fn.v | 3 +++ vlib/v/tests/project_issue_21476/foo.v | 7 +++++++ vlib/v/tests/project_issue_21476/main.v | 12 ++++++++++++ .../project_issue_21476/project_compiles_test.v | 5 +++++ vlib/v/tests/project_issue_21476/v.mod | 0 5 files changed, 27 insertions(+) create mode 100644 vlib/v/tests/project_issue_21476/foo.v create mode 100644 vlib/v/tests/project_issue_21476/main.v create mode 100644 vlib/v/tests/project_issue_21476/project_compiles_test.v create mode 100644 vlib/v/tests/project_issue_21476/v.mod diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index b4dfe7bd1..07acc2a77 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -1157,6 +1157,9 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast. func = f node.name = qualified_name unsafe { c.table.fns[qualified_name].usages++ } + if !c.table.register_fn_concrete_types(f.name, concrete_types) { + c.need_recheck_generic_fns = true + } break } } diff --git a/vlib/v/tests/project_issue_21476/foo.v b/vlib/v/tests/project_issue_21476/foo.v new file mode 100644 index 000000000..4df997fd1 --- /dev/null +++ b/vlib/v/tests/project_issue_21476/foo.v @@ -0,0 +1,7 @@ +module zmod_foo + +pub struct Foo[T] {} + +pub fn Foo.new[T](embed T) &Foo[T] { + return &Foo[T]{} +} diff --git a/vlib/v/tests/project_issue_21476/main.v b/vlib/v/tests/project_issue_21476/main.v new file mode 100644 index 000000000..21188ea3a --- /dev/null +++ b/vlib/v/tests/project_issue_21476/main.v @@ -0,0 +1,12 @@ +module main + +import zmod_foo { Foo } + +struct Bar {} + +fn main() { + // note: will succeed with foo.Foo + f := Foo.new[Bar](Bar{}) + + println(typeof(f).name) +} diff --git a/vlib/v/tests/project_issue_21476/project_compiles_test.v b/vlib/v/tests/project_issue_21476/project_compiles_test.v new file mode 100644 index 000000000..edb1e414d --- /dev/null +++ b/vlib/v/tests/project_issue_21476/project_compiles_test.v @@ -0,0 +1,5 @@ +module main + +fn test_compiles() { + assert true +} diff --git a/vlib/v/tests/project_issue_21476/v.mod b/vlib/v/tests/project_issue_21476/v.mod new file mode 100644 index 000000000..e69de29bb -- 2.39.5