mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: better error message for incorrect mut x :=
This commit is contained in:
parent
3a146a6dbe
commit
5d484bf022
@ -851,9 +851,15 @@ fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
|
||||
// 1, a, c ... } // multi-expression
|
||||
// a, mut b ... :=/= // multi-assign
|
||||
// collect things upto hard boundaries
|
||||
$if debug {
|
||||
p.warn('xxx')
|
||||
}
|
||||
tok := p.tok
|
||||
left, left_comments := p.expr_list()
|
||||
left0 := left[0]
|
||||
if tok.kind == .key_mut && p.tok.kind != .decl_assign {
|
||||
p.error('expecting `:=` (e.g. `mut x :=`)')
|
||||
}
|
||||
if p.tok.kind in [.assign, .decl_assign] || p.tok.kind.is_assign() {
|
||||
return p.partial_assign_stmt(left, left_comments)
|
||||
} else if is_top_level && tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock] &&
|
||||
|
Loading…
Reference in New Issue
Block a user