checker: better error message for incorrect `mut x :=`

pull/6341/head
Alexander Medvednikov 2020-09-09 17:27:12 +02:00
parent 3a146a6dbe
commit 5d484bf022
1 changed files with 6 additions and 0 deletions

View File

@ -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] &&