fmt: keep C. prefix for concrete type used in a generic fn call (#22517)

This commit is contained in:
Felipe Pena 2024-10-13 14:14:23 -03:00 committed by GitHub
parent 55ae30cba4
commit df4c6ac739
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -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.') { } else if tsym.language == .js && !tsym.name.starts_with('JS.') {
name = 'JS.' + name name = 'JS.' + name
} }
if tsym.language == .c {
name = 'C.' + name
}
f.write(name) f.write(name)
f.mark_types_import_as_used(concrete_type) f.mark_types_import_as_used(concrete_type)
if i != node.concrete_types.len - 1 { if i != node.concrete_types.len - 1 {

View File

@ -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)
}