checker: c2v array fix (#14426)

playX 2022-05-16 21:08:41 +00:00 committed by Jef Roosens
parent ec5559a379
commit 15b84567ec
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 14 additions and 0 deletions

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