parser: fix single decl/assign bug & update error msg

pull/2272/head
joe-conigliaro 2019-10-10 04:54:52 +11:00 committed by Alexander Medvednikov
parent b1da59845e
commit 236b34c009
1 changed files with 2 additions and 2 deletions

View File

@ -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)