mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check fn call argument mismatch for array struct type (#18975)
This commit is contained in:
parent
94de6f62b2
commit
7d6fd9dade
@ -350,7 +350,8 @@ fn (mut c Checker) check_basic(got ast.Type, expected ast.Type) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// TODO: use sym so it can be absorbed into below [.voidptr, .any] logic
|
// TODO: use sym so it can be absorbed into below [.voidptr, .any] logic
|
||||||
if expected.idx() == ast.array_type_idx || got.idx() == ast.array_type_idx {
|
if (expected.idx() == ast.array_type_idx && c.table.final_sym(got).kind == .array)
|
||||||
|
|| (got.idx() == ast.array_type_idx && c.table.final_sym(expected).kind == .array) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
got_sym, exp_sym := c.table.sym(got), c.table.sym(expected)
|
got_sym, exp_sym := c.table.sym(got), c.table.sym(expected)
|
||||||
|
7
vlib/v/checker/tests/fn_call_arg_array_mismatch_err.out
Normal file
7
vlib/v/checker/tests/fn_call_arg_array_mismatch_err.out
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
vlib/v/checker/tests/fn_call_arg_array_mismatch_err.vv:9:36: error: cannot use `string` as `array` in argument 2 to `os.write_file_array`
|
||||||
|
7 |
|
||||||
|
8 | fn main() {
|
||||||
|
9 | os.write_file_array(service_path, service_file) or {
|
||||||
|
| ~~~~~~~~~~~~
|
||||||
|
10 | eprintln('Error: write file service')
|
||||||
|
11 | exit(1)
|
13
vlib/v/checker/tests/fn_call_arg_array_mismatch_err.vv
Normal file
13
vlib/v/checker/tests/fn_call_arg_array_mismatch_err.vv
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
const (
|
||||||
|
service_file = '[Unit]'
|
||||||
|
service_path = 'dockerman.service'
|
||||||
|
)
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
os.write_file_array(service_path, service_file) or {
|
||||||
|
eprintln('Error: write file service')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user