From 687ee535ea1d01fa3c2243cb9fe4a6a252947547 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 15 Apr 2026 05:29:36 +0300 Subject: [PATCH] cgen: fix cgen error for generic function type inferred implicitly (fixes #25388) --- .../options/option_generic_inferred_call_test.v | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 vlib/v/tests/options/option_generic_inferred_call_test.v diff --git a/vlib/v/tests/options/option_generic_inferred_call_test.v b/vlib/v/tests/options/option_generic_inferred_call_test.v new file mode 100644 index 000000000..98c7ae0e4 --- /dev/null +++ b/vlib/v/tests/options/option_generic_inferred_call_test.v @@ -0,0 +1,16 @@ +fn unwrap[T](val ?T) T { + if u_val := val { + return u_val + } + + return T{} +} + +fn test_option_generic_function_call_can_infer_type_implicitly() { + toto := ?int(1) + implicit := unwrap(toto) + explicit := unwrap[int](toto) + + assert implicit == 1 + assert explicit == 1 +} -- 2.39.5