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

compiler: clears MainFn when recompile on repl

This commit is contained in:
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++ f.var_idx++
} }
fn (f mut Fn) clear_vars() {
f.var_idx = 0
f.local_vars = []Var
}
// vlib header file? // vlib header file?
fn (p mut Parser) is_sig() bool { fn (p mut Parser) is_sig() bool {
return (p.build_mode == DEFAULT_MODE || p.build_mode == BUILD) && 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 == '' { if p.cur_fn.name == '' {
p.cur_fn = MainFn p.cur_fn = MainFn
if p.is_repl {
p.cur_fn.clear_vars()
}
} }
start := p.cgen.lines.len start := p.cgen.lines.len
p.statement(true) p.statement(true)