mirror of
https://github.com/vlang/v.git
synced 2025-09-15 02:18:47 -04:00
fmt: keep C.
prefix for concrete type used in a generic fn call (#22517)
This commit is contained in:
parent
55ae30cba4
commit
df4c6ac739
@ -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 {
|
||||
|
16
vlib/v/fmt/tests/fn_call_concrete_type_keep.vv
Normal file
16
vlib/v/fmt/tests/fn_call_concrete_type_keep.vv
Normal 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)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user