Skip to content

Commit

Permalink
fmt: keep C. prefix for concrete type used in a generic fn call (vl…
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp authored Oct 13, 2024
1 parent 55ae30c commit df4c6ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vlib/v/fmt/fmt.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions vlib/v/fmt/tests/fn_call_concrete_type_keep.vv
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit df4c6ac

Please sign in to comment.