diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 9254e9b2df87c7..4c950cae196797 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -2126,6 +2126,9 @@ fn (mut f Fmt) write_generic_call_if_require(node ast.CallExpr) { } else if tsym.language == .js && !tsym.name.starts_with('JS.') { name = 'JS.' + name } + if tsym.language == .c { + name = 'C.' + name + } f.write(name) f.mark_types_import_as_used(concrete_type) if i != node.concrete_types.len - 1 { diff --git a/vlib/v/fmt/tests/fn_call_concrete_type_keep.vv b/vlib/v/fmt/tests/fn_call_concrete_type_keep.vv new file mode 100644 index 00000000000000..502c5348f3228b --- /dev/null +++ b/vlib/v/fmt/tests/fn_call_concrete_type_keep.vv @@ -0,0 +1,16 @@ +fn to_v_array[T](d &T, len u32) []T { + mut ret := unsafe { []T{len: int(len)} } + for i in 0 .. len { + unsafe { + ret[i] = d[i] + } + } + unsafe { + free(d) + } + return ret +} + +fn main() { + to_v_array[C.Foo](C.Foo{}, 123.2) +}