Revert "parser: fix programs without fn main"

This reverts commit bf21108fdb.
pull/2330/head
Alexander Medvednikov 2019-10-13 17:55:12 +03:00
parent b1806b57d8
commit 61af044316
1 changed files with 7 additions and 4 deletions

View File

@ -395,18 +395,21 @@ fn (p mut Parser) parse(pass Pass) {
if p.pref.is_script && !p.pref.is_test {
// cur_fn is empty since there was no fn main declared
// we need to set it to save and find variables
if p.first_pass() {
if p.cur_fn.name == '' {
p.set_current_fn( MainFn )
}
return
}
if p.cur_fn.name == '' {
p.set_current_fn( MainFn )
if p.pref.is_repl {
if p.first_pass() {
return
}
p.clear_vars()
}
}
mut start := p.cgen.lines.len
p.statement(true)
if start > 0 && p.cgen.lines[start - 1] != '' && p.cgen.fn_main != '' {
if p.cgen.lines[start - 1] != '' && p.cgen.fn_main != '' {
start--
}
p.genln('')