diff --git a/vlib/v/checker/check_types.v b/vlib/v/checker/check_types.v index 8b69246b95..39095b073d 100644 --- a/vlib/v/checker/check_types.v +++ b/vlib/v/checker/check_types.v @@ -350,7 +350,8 @@ fn (mut c Checker) check_basic(got ast.Type, expected ast.Type) bool { return true } // 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 } got_sym, exp_sym := c.table.sym(got), c.table.sym(expected) diff --git a/vlib/v/checker/tests/fn_call_arg_array_mismatch_err.out b/vlib/v/checker/tests/fn_call_arg_array_mismatch_err.out new file mode 100644 index 0000000000..789d65e8e5 --- /dev/null +++ b/vlib/v/checker/tests/fn_call_arg_array_mismatch_err.out @@ -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) diff --git a/vlib/v/checker/tests/fn_call_arg_array_mismatch_err.vv b/vlib/v/checker/tests/fn_call_arg_array_mismatch_err.vv new file mode 100644 index 0000000000..9f3dc8be4b --- /dev/null +++ b/vlib/v/checker/tests/fn_call_arg_array_mismatch_err.vv @@ -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) + } +}