From 5f4e74532e01c94087658f5236bdf903e0f47ab9 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2026 12:45:28 +0300 Subject: [PATCH] cgen: cgen error when changing the signature of a function with a specialized generic struct parameter, that is not called (fixes #23014) --- ...s_unused_specialized_fn_array_param_test.v | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 vlib/v/tests/generics/generics_unused_specialized_fn_array_param_test.v diff --git a/vlib/v/tests/generics/generics_unused_specialized_fn_array_param_test.v b/vlib/v/tests/generics/generics_unused_specialized_fn_array_param_test.v new file mode 100644 index 000000000..6e9b27a27 --- /dev/null +++ b/vlib/v/tests/generics/generics_unused_specialized_fn_array_param_test.v @@ -0,0 +1,30 @@ +struct Context[U] { + name string + x U +} + +type Handler[U] = fn (ctx Context[U]) ? + +fn f1[U](ctx Context[U]) ? {} + +fn f2[U](ctx Context[U]) ? {} + +// Keep these unused specialized signatures distinct; issue #23014 failed in cgen here. +fn f3(ctx Context[int]) ? {} + +fn f4(ctx Context[u8]) ? {} + +struct App[U] { + x U +} + +fn (mut app App[U]) get(prefix string, handlers []Handler[U]) { + assert prefix.len > 0 + assert handlers.len == 2 +} + +fn test_generics_unused_specialized_fn_array_param() { + mut app := App[u64]{} + app.get('abc', [f1[u64], f2[u64]]) + assert true +} -- 2.39.5