diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index c8a90c36e3..ab61db3a1c 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1929,7 +1929,7 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type { } } if has_generic_generic { - if c.mod != '' { + if c.mod != '' && !fn_name.starts_with('${c.mod}.') { // Need to prepend the module when adding a generic type to a function c.table.register_fn_generic_types(c.mod + '.' + fn_name, generic_types) } else { diff --git a/vlib/v/tests/generics_in_generics_test.v b/vlib/v/tests/generics_in_generics_test.v new file mode 100644 index 0000000000..3e2149d548 --- /dev/null +++ b/vlib/v/tests/generics_in_generics_test.v @@ -0,0 +1,12 @@ +fn gen_fn2(e T) string { + return '$e.str()' +} + +fn gen_fn(e T) string { + return gen_fn2(e) +} + +fn test_generics_in_generics() { + assert gen_fn(u64(42)) == '42' + assert gen_fn('42') == '42' +}