Revert "checker: remove more unnecessary `void` errors"

This reverts commit 89c1e7f980.
master
Alexander Medvednikov 2022-05-07 11:03:12 +03:00
parent 35cfa0da7c
commit ca42ace367
2 changed files with 2 additions and 4 deletions

View File

@ -3873,8 +3873,7 @@ pub fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type {
} }
} }
if typ_sym.kind !in [.array, .array_fixed, .string, .map] && !typ.is_ptr() if typ_sym.kind !in [.array, .array_fixed, .string, .map] && !typ.is_ptr()
&& typ !in [ast.byteptr_type, ast.charptr_type] && !typ.has_flag(.variadic) && typ !in [ast.byteptr_type, ast.charptr_type] && !typ.has_flag(.variadic) {
&& typ != ast.void_type {
c.error('type `$typ_sym.name` does not support indexing', node.pos) c.error('type `$typ_sym.name` does not support indexing', node.pos)
} }
if typ.has_flag(.optional) { if typ.has_flag(.optional) {

View File

@ -48,8 +48,7 @@ pub fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
c.expected_type = ast.bool_type c.expected_type = ast.bool_type
cond_typ := c.unwrap_generic(c.expr(branch.cond)) cond_typ := c.unwrap_generic(c.expr(branch.cond))
if (cond_typ.idx() != ast.bool_type_idx || cond_typ.has_flag(.optional)) if (cond_typ.idx() != ast.bool_type_idx || cond_typ.has_flag(.optional))
&& !c.pref.translated && !c.file.is_translated && !c.pref.translated && !c.file.is_translated {
&& cond_typ.idx() != ast.void_type_idx {
c.error('non-bool type `${c.table.type_to_str(cond_typ)}` used as if condition', c.error('non-bool type `${c.table.type_to_str(cond_typ)}` used as if condition',
branch.cond.pos()) branch.cond.pos())
} }