mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fix
This commit is contained in:
parent
fc779c3e13
commit
a897e98da4
3 changed files with 26 additions and 0 deletions
|
@ -2576,6 +2576,9 @@ fn (mut c Checker) method_call(mut node ast.CallExpr, mut continue_check &bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if exp_arg_typ.has_flag(.generic) {
|
if exp_arg_typ.has_flag(.generic) {
|
||||||
|
if arg.expr is ast.ArrayInit && arg.expr.exprs.len == 0 {
|
||||||
|
c.error('cannot use empty array as generic argument', arg.pos)
|
||||||
|
}
|
||||||
method_concrete_types := if method_generic_names_len == rec_concrete_types.len {
|
method_concrete_types := if method_generic_names_len == rec_concrete_types.len {
|
||||||
rec_concrete_types
|
rec_concrete_types
|
||||||
} else {
|
} else {
|
||||||
|
|
13
vlib/v/checker/tests/empty_arr_to_generic_param_err.out
Normal file
13
vlib/v/checker/tests/empty_arr_to_generic_param_err.out
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
vlib/v/checker/tests/empty_arr_to_generic_param_err.vv:8:4: error: cannot use empty array as generic argument
|
||||||
|
6 |
|
||||||
|
7 | fn main() {
|
||||||
|
8 | t([])
|
||||||
|
| ~~
|
||||||
|
9 | Foo{}.t([])
|
||||||
|
10 | }
|
||||||
|
vlib/v/checker/tests/empty_arr_to_generic_param_err.vv:9:10: error: cannot use empty array as generic argument
|
||||||
|
7 | fn main() {
|
||||||
|
8 | t([])
|
||||||
|
9 | Foo{}.t([])
|
||||||
|
| ~~
|
||||||
|
10 | }
|
10
vlib/v/checker/tests/empty_arr_to_generic_param_err.vv
Normal file
10
vlib/v/checker/tests/empty_arr_to_generic_param_err.vv
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
fn t[T](a []T) {}
|
||||||
|
|
||||||
|
struct Foo {}
|
||||||
|
|
||||||
|
fn (t &Foo) t[T](a []T) {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
t([])
|
||||||
|
Foo{}.t([])
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue