mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix single decl/assign bug & update error msg
This commit is contained in:
parent
b1da59845e
commit
236b34c009
@ -1472,8 +1472,8 @@ fn (p mut Parser) var_decl() {
|
|||||||
p.error('expected `=` or `:=`')
|
p.error('expected `=` or `:=`')
|
||||||
}
|
}
|
||||||
// all vars on left of `:=` already defined (or `_`)
|
// all vars on left of `:=` already defined (or `_`)
|
||||||
if is_decl_assign && /*var_names.len > 1 &&*/ new_vars == 0 {
|
if is_decl_assign && var_names.len == 1 && var_names[0] == '_' {
|
||||||
p.error_with_token_index('no new variables on left side of `:=`', var_token_idxs.last())
|
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] }
|
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)
|
t := p.gen_var_decl(p.var_decl_name, is_static)
|
||||||
|
Loading…
Reference in New Issue
Block a user