Skip to content

Commit

Permalink
Revert "checker: remove more unnecessary void errors"
Browse files Browse the repository at this point in the history
This reverts commit 89c1e7f.
  • Loading branch information
medvednikov committed May 7, 2022
1 parent 35cfa0d commit ca42ace
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -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()
&& typ !in [ast.byteptr_type, ast.charptr_type] && !typ.has_flag(.variadic)
&& typ != ast.void_type {
&& typ !in [ast.byteptr_type, ast.charptr_type] && !typ.has_flag(.variadic) {
c.error('type `$typ_sym.name` does not support indexing', node.pos)
}
if typ.has_flag(.optional) {
Expand Down
3 changes: 1 addition & 2 deletions vlib/v/checker/if.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ pub fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
c.expected_type = ast.bool_type
cond_typ := c.unwrap_generic(c.expr(branch.cond))
if (cond_typ.idx() != ast.bool_type_idx || cond_typ.has_flag(.optional))
&& !c.pref.translated && !c.file.is_translated
&& cond_typ.idx() != ast.void_type_idx {
&& !c.pref.translated && !c.file.is_translated {
c.error('non-bool type `${c.table.type_to_str(cond_typ)}` used as if condition',
branch.cond.pos())
}
Expand Down

0 comments on commit ca42ace

Please sign in to comment.