mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: avoid redeclaration of var during reassignment with optional value
This commit is contained in:
parent
15415b2aae
commit
868d6c808b
@ -116,7 +116,7 @@ fn (p mut Parser) gen_handle_option_or_else(_typ, name string, fn_call_ph int) s
|
||||
is_mut: false
|
||||
is_used: true
|
||||
})
|
||||
if is_assign && !name.contains('.') {
|
||||
if is_assign && !name.contains('.') && !p.is_var_decl {
|
||||
// don't initialize struct fields
|
||||
p.genln('$typ $name;')
|
||||
}
|
||||
@ -717,4 +717,3 @@ fn (p mut Parser) gen_array_push(ph int, typ, expr_type, tmp, elm_type string) {
|
||||
p.gen('), $tmp, $elm_type)')
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user