Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Jul 1, 2024
1 parent 1b9d391 commit 646379e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions vlib/v/checker/containers.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 646379e

Please sign in to comment.