mirror of
https://github.com/vlang/v.git
synced 2025-09-12 00:46:55 -04:00
parent
6a98e38f0d
commit
3f76b69165
@ -1612,6 +1612,12 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
|
|||||||
c.error('cannot use `${got_typ_str}` as `${expected_typ_str}` in argument ${i + 1} to `${fn_name}`',
|
c.error('cannot use `${got_typ_str}` as `${expected_typ_str}` in argument ${i + 1} to `${fn_name}`',
|
||||||
call_arg.pos)
|
call_arg.pos)
|
||||||
}
|
}
|
||||||
|
if call_arg.expr is ast.ArrayDecompose && arg_typ.idx() != final_param_typ.idx() {
|
||||||
|
expected_type_str := c.table.type_to_str(param.typ)
|
||||||
|
got_type_str := c.table.type_to_str(arg_typ)
|
||||||
|
c.error('cannot use `${got_type_str}` as `${expected_type_str}` in argument ${i + 1} to `${fn_name}`',
|
||||||
|
call_arg.pos)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if param.typ.is_ptr() && !param.is_mut && !call_arg.typ.is_any_kind_of_pointer()
|
if param.typ.is_ptr() && !param.is_mut && !call_arg.typ.is_any_kind_of_pointer()
|
||||||
|
20
vlib/v/checker/tests/decompose_interface_err.out
Normal file
20
vlib/v/checker/tests/decompose_interface_err.out
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
vlib/v/checker/tests/decompose_interface_err.vv:3:8: warning: module 'arrays' is imported but never used
|
||||||
|
1 | module main
|
||||||
|
2 |
|
||||||
|
3 | import arrays
|
||||||
|
| ~~~~~~
|
||||||
|
4 |
|
||||||
|
5 | interface Value {}
|
||||||
|
vlib/v/checker/tests/decompose_interface_err.vv:17:2: warning: unused variable: `region_id`
|
||||||
|
15 | 'AF',
|
||||||
|
16 | ]
|
||||||
|
17 | region_id := 'something'
|
||||||
|
| ~~~~~~~~~
|
||||||
|
18 | some_function(...country_ids)
|
||||||
|
19 | }
|
||||||
|
vlib/v/checker/tests/decompose_interface_err.vv:18:16: error: cannot use `string` as `Value` in argument 1 to `some_function`
|
||||||
|
16 | ]
|
||||||
|
17 | region_id := 'something'
|
||||||
|
18 | some_function(...country_ids)
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
19 | }
|
19
vlib/v/checker/tests/decompose_interface_err.vv
Normal file
19
vlib/v/checker/tests/decompose_interface_err.vv
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
import arrays
|
||||||
|
|
||||||
|
interface Value {}
|
||||||
|
|
||||||
|
fn some_function(values ...Value) {
|
||||||
|
println(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
country_ids := [
|
||||||
|
'AD',
|
||||||
|
'AE',
|
||||||
|
'AF',
|
||||||
|
]
|
||||||
|
region_id := 'something'
|
||||||
|
some_function(...country_ids)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user