Skip to content

Commit

Permalink
checker: a minor cleanup (#19855)
Browse files Browse the repository at this point in the history
  • Loading branch information
shove70 committed Nov 14, 2023
1 parent 8b71639 commit e4bae91
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions vlib/v/checker/assign.v
Expand Up @@ -290,22 +290,22 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
} else if left.info !is ast.IdentVar {
c.error('cannot assign to ${left.kind} `${left.name}`', left.pos)
} else {
if is_decl || is_shared_re_assign {
if is_decl {
c.check_valid_snake_case(left.name, 'variable name', left.pos)
if reserved_type_names_chk.matches(left.name) {
c.error('invalid use of reserved type `${left.name}` as a variable name',
left.pos)
}
if right is ast.Nil && !c.inside_unsafe {
// `x := unsafe { nil }` is allowed,
// as well as:
// `unsafe {
// x := nil
// println(x)
// }`
c.error('use of untyped nil in assignment (use `unsafe` | ${c.inside_unsafe})',
right.pos())
}
}
if (is_decl || is_shared_re_assign) && right is ast.Nil && !c.inside_unsafe {
// `x := unsafe { nil }` is allowed,
// as well as:
// `unsafe {
// x := nil
// println(x)
// }`
c.error('use of untyped nil in assignment (use `unsafe` | ${c.inside_unsafe})',
right.pos())
}
mut ident_var_info := left.info as ast.IdentVar
if ident_var_info.share == .shared_t || is_shared_re_assign {
Expand Down

0 comments on commit e4bae91

Please sign in to comment.