From 5d484bf02269e47e92fd833d37d53683f3221852 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 9 Sep 2020 17:27:12 +0200 Subject: [PATCH] checker: better error message for incorrect `mut x :=` --- vlib/v/parser/parser.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index ae3d086d31..f77d67db69 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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] &&