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

parser: fix v_panic due to -pos in unused var warning (with tcc)

This commit is contained in:
Delyan Angelov 2020-05-15 20:11:21 +03:00
parent c4ca6a9113
commit 5d0cc0944e

View File

@ -66,14 +66,14 @@ fn (mut p Parser) for_stmt() ast.Stmt {
}
} else if p.peek_tok.kind in [.key_in, .comma] {
// `for i in vals`, `for i in start .. end`
key_var_pos := p.tok.position()
mut val_var_pos := p.tok.position()
mut key_var_name := ''
mut val_var_name := p.check_name()
if p.tok.kind == .comma {
p.next()
key_var_pos := val_var_pos
val_var_pos = p.tok.position()
key_var_name = val_var_name
val_var_pos = p.tok.position()
val_var_name = p.check_name()
if p.scope.known_var(key_var_name) {
p.error('redefinition of key iteration variable `$key_var_name`')