compiler: fix mark_var_used()

pull/2096/head
joe-conigliaro 2019-09-24 13:18:06 +10:00 committed by Alexander Medvednikov
parent f7d8fb0cf4
commit a44a03f9a5
2 changed files with 5 additions and 5 deletions

View File

@ -69,7 +69,7 @@ fn (p mut Parser) open_scope() {
}
fn (p mut Parser) mark_var_used(v Var) {
if v.idx == -1 {
if v.idx == -1 || v.idx >= p.local_vars.len {
return
}
p.local_vars[v.idx].is_used = true

View File

@ -276,10 +276,10 @@ fn (p mut Parser) parse(pass Pass) {
p.cgen.consts << g
case Token.eof:
//p.log('end of parse()')
if p.is_script && !p.pref.is_test {
p.set_current_fn( MainFn )
p.check_unused_variables()
}
// if p.is_script && !p.pref.is_test {
// p.set_current_fn( MainFn )
// p.check_unused_variables()
// }
if !p.first_pass() && !p.pref.is_repl {
p.check_unused_imports()
}