1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: c2v array fix (#14426)

This commit is contained in:
playX 2022-05-16 21:08:41 +00:00 committed by GitHub
parent 32dd801201
commit bc397bb0e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -958,6 +958,9 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
if param.typ == ast.voidptr_type_idx || arg_typ == ast.voidptr_type_idx {
continue
}
if param.typ.is_any_kind_of_pointer() && arg_typ.is_any_kind_of_pointer() {
continue
}
param_typ_sym_ := c.table.sym(c.table.unaliased_type(param.typ))
arg_typ_sym_ := c.table.sym(c.table.unaliased_type(arg_typ))
// Allow `[32]i8` as `&i8` etc
@ -968,6 +971,17 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
&& (typ_is_number || c.table.unaliased_type(arg_typ).is_any_kind_of_pointer())) {
continue
}
// Allow `[N]anyptr` as `[N]anyptr`
if arg_typ_sym_.kind == .array && param_typ_sym_.kind == .array {
if (arg_typ_sym_.info as ast.Array).elem_type.is_any_kind_of_pointer()
&& (param_typ_sym_.info as ast.Array).elem_type.is_any_kind_of_pointer() {
continue
}
} else if arg_typ_sym_.kind == .array_fixed && param_typ_sym_.kind == .array_fixed {
if (arg_typ_sym_.info as ast.ArrayFixed).elem_type.is_any_kind_of_pointer()&& (param_typ_sym_.info as ast.ArrayFixed).elem_type.is_any_kind_of_pointer() {
continue
}
}
// Allow `int` as `&i8`
if param.typ.is_any_kind_of_pointer() && typ_is_number {
continue