From bc397bb0e174ab8afe2b28dbf148b5ed0345cdb2 Mon Sep 17 00:00:00 2001 From: playX Date: Mon, 16 May 2022 21:08:41 +0000 Subject: [PATCH] checker: c2v array fix (#14426) --- vlib/v/checker/fn.v | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 24a55034f0..7d58add0ca 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -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