v2 / vlib / v / tests / generics / generic_fn_array_infer_var_test.v
20 lines · 17 sloc · 439 bytes · 7b9b3dd926b267456219e559dad4fc3d2f3e1da5
Raw
1fn function_that_receives_an_array_of_generic_type[T](array []T) {
2 assert array.len == 0
3}
4
5fn function_that_returns_an_array_of_generic_type[T]() []T {
6 return []
7}
8
9fn func[T]() {
10 res := function_that_returns_an_array_of_generic_type[T]()
11 function_that_receives_an_array_of_generic_type(res)
12 assert res.len == 0
13 function_that_receives_an_array_of_generic_type[T](res)
14}
15
16fn test_main() {
17 func[string]()
18 func[int]()
19 func[f64]()
20}
21