From 146051b231ea3b6c56bcdd6830677a2809451fbd Mon Sep 17 00:00:00 2001 From: playX Date: Tue, 3 May 2022 17:44:45 +0000 Subject: [PATCH] checker: allow fixed array to pointer and vice versa when translated (#14275) --- vlib/v/checker/check_types.v | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vlib/v/checker/check_types.v b/vlib/v/checker/check_types.v index de418af4dc..632167576b 100644 --- a/vlib/v/checker/check_types.v +++ b/vlib/v/checker/check_types.v @@ -43,6 +43,18 @@ pub fn (mut c Checker) check_types(got ast.Type, expected ast.Type) bool { // Allow fixed arrays as `&i8` etc if expected_sym.is_number() { return true + } else if expected.is_any_kind_of_pointer() { + return true + } + } else if expected_sym.kind == .array_fixed { + if got_sym.is_number() && got.is_any_kind_of_pointer() { + return true + } else if got_sym.kind == .array { + info := expected_sym.info as ast.ArrayFixed + info2 := got_sym.info as ast.Array + if c.check_types(info.elem_type, info2.elem_type) { + return true + } } } if expected_sym.kind == .enum_ && got_sym.is_number() {