mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix fn call with generic []T arg (#16781)
This commit is contained in:
parent
b171102b03
commit
0f37ff197b
@ -263,8 +263,8 @@ fn (mut c Checker) check_expected_call_arg(got ast.Type, expected_ ast.Type, lan
|
||||
return
|
||||
}
|
||||
} else {
|
||||
got_typ_sym := c.table.sym(got)
|
||||
expected_typ_sym := c.table.sym(expected_)
|
||||
got_typ_sym := c.table.sym(c.unwrap_generic(got))
|
||||
expected_typ_sym := c.table.sym(c.unwrap_generic(expected_))
|
||||
|
||||
// Check on Generics types, there are some case where we have the following case
|
||||
// `&Type[int] == &Type[]`. This is a common case we are implementing a function
|
||||
|
15
vlib/v/tests/fn_call_generic_array_arg_test.v
Normal file
15
vlib/v/tests/fn_call_generic_array_arg_test.v
Normal file
@ -0,0 +1,15 @@
|
||||
fn f64_fun(x []f64) f64 {
|
||||
return x[0] + x[1]
|
||||
}
|
||||
|
||||
fn t_fun[T](x []T) T {
|
||||
$if T is f64 {
|
||||
return f64_fun(x)
|
||||
} $else {
|
||||
return T(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
assert t_fun([1.0, 2.0]) == 3.0
|
||||
}
|
Loading…
Reference in New Issue
Block a user