From 646379ee4bc26f90db01889aa166cb799f0a44f5 Mon Sep 17 00:00:00 2001 From: Swastik Date: Tue, 2 Jul 2024 00:42:41 +0530 Subject: [PATCH] fix test --- vlib/v/checker/containers.v | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/vlib/v/checker/containers.v b/vlib/v/checker/containers.v index 356cc9969ed7d5..e8cf31069730f9 100644 --- a/vlib/v/checker/containers.v +++ b/vlib/v/checker/containers.v @@ -205,14 +205,16 @@ fn (mut c Checker) array_init(mut node ast.ArrayInit) ast.Type { c.error('cannot have non-pointer of type `${c.table.type_to_str(typ)}` in a pointer array of type `${c.table.type_to_str(elem_type)}`', expr.pos()) } - if elem_type != ast.nil_type && typ.idx() == ast.nil_type_idx { - c.error('cannot have `unsafe { nil }` inside a `${c.table.type_to_str(elem_type)}` array', - expr.pos()) - } + if !c.inside_unsafe { + if elem_type != ast.nil_type && typ.idx() == ast.nil_type_idx { + c.error('cannot have `unsafe { nil }` inside a `${c.table.type_to_str(elem_type)}` array', + expr.pos()) + } - if elem_type == ast.nil_type && typ.idx() != ast.nil_type_idx { - c.error('cannot have `${c.table.type_to_str(typ)}` inside a `${c.table.type_to_str(elem_type)}` array', - expr.pos()) + if elem_type == ast.nil_type && typ.idx() != ast.nil_type_idx { + c.error('cannot have `${c.table.type_to_str(typ)}` inside a `${c.table.type_to_str(elem_type)}` array', + expr.pos()) + } } } if expr !is ast.TypeNode {