From 236b34c00935b8a0928fca3956aec0f811095ce4 Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Thu, 10 Oct 2019 04:54:52 +1100 Subject: [PATCH] parser: fix single decl/assign bug & update error msg --- compiler/parser.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/parser.v b/compiler/parser.v index b032f0e807..0438e150a9 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1472,8 +1472,8 @@ fn (p mut Parser) var_decl() { p.error('expected `=` or `:=`') } // all vars on left of `:=` already defined (or `_`) - if is_decl_assign && /*var_names.len > 1 &&*/ new_vars == 0 { - p.error_with_token_index('no new variables on left side of `:=`', var_token_idxs.last()) + if is_decl_assign && var_names.len == 1 && var_names[0] == '_' { + p.error_with_token_index('use `=` instead of `:=`', var_token_idxs.last()) } p.var_decl_name = if var_names.len > 1 { '_V_mret_'+var_names.join('_') } else { var_names[0] } t := p.gen_var_decl(p.var_decl_name, is_static)