compiler: clears MainFn when recompile on repl

pull/769/head
Henrixounez 2019-06-28 17:15:52 +02:00 committed by Alexander Medvednikov
parent 748c45203d
commit b6b313d246
2 changed files with 8 additions and 0 deletions

View File

@ -88,6 +88,11 @@ fn (f mut Fn) register_var(v Var) {
f.var_idx++
}
fn (f mut Fn) clear_vars() {
f.var_idx = 0
f.local_vars = []Var
}
// vlib header file?
fn (p mut Parser) is_sig() bool {
return (p.build_mode == DEFAULT_MODE || p.build_mode == BUILD) &&

View File

@ -249,6 +249,9 @@ fn (p mut Parser) parse() {
}
if p.cur_fn.name == '' {
p.cur_fn = MainFn
if p.is_repl {
p.cur_fn.clear_vars()
}
}
start := p.cgen.lines.len
p.statement(true)