1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

for: check for redefinitions

This commit is contained in:
Alexander Medvednikov
2019-12-14 19:58:55 +03:00
parent be2b5698c5
commit 2e23592264
3 changed files with 15 additions and 6 deletions

View File

@ -103,6 +103,9 @@ fn (p mut Parser) for_st() {
}
// Register temp vars
if i != '_' {
if p.known_var(i) {
p.error('redefinition of `$i`')
}
p.register_var(Var {
name: i
typ: i_var_type
@ -111,6 +114,9 @@ fn (p mut Parser) for_st() {
})
}
if val != '_' {
if p.known_var(val) {
p.error('redefinition of `$val`')
}
p.register_var(Var {
name: val
typ: typ
@ -182,6 +188,9 @@ fn (p mut Parser) for_st() {
// println('for typ=$typ vartyp=$var_typ')
// Register temp var
if val != '_' {
if p.known_var(val) {
p.error('redefinition of `$val`')
}
p.register_var(Var {
name: val
typ: typ