mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check generics fn called outside of generic fn (#9984)
This commit is contained in:
parent
ddc003380c
commit
1d045e5496
@ -2135,6 +2135,10 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
|
|||||||
concrete_types << concrete_type
|
concrete_types << concrete_type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if c.cur_fn.cur_concrete_types.len == 0 && has_generic {
|
||||||
|
c.error('generic fn using generic types cannot be called outside of generic fn',
|
||||||
|
call_expr.pos)
|
||||||
|
}
|
||||||
if has_generic {
|
if has_generic {
|
||||||
mut no_exists := true
|
mut no_exists := true
|
||||||
if c.mod != '' && !fn_name.contains('.') {
|
if c.mod != '' && !fn_name.contains('.') {
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.vv:4:2: error: generic fn using generic types cannot be called outside of generic fn
|
||||||
|
2 |
|
||||||
|
3 | fn main() {
|
||||||
|
4 | foo<T>()
|
||||||
|
| ~~~~~~~~
|
||||||
|
5 | }
|
@ -0,0 +1,5 @@
|
|||||||
|
fn foo<T>() {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo<T>()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user