do not allow redefinition in `x := opt() {`

pull/3009/head
Alexander Medvednikov 2019-12-07 23:09:48 +03:00
parent b79588dc69
commit 8ebc2fe601
1 changed files with 3 additions and 0 deletions

View File

@ -231,6 +231,9 @@ fn (p mut Parser) if_statement(is_expr bool, elif_depth int) string {
p.check_not_reserved()
option_tmp := p.get_tmp()
var_name := p.lit
if p.known_var(var_name) {
p.error('redefinition of `$var_name`')
}
p.next()
p.check(.decl_assign)
p.is_var_decl = true