mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix script and repl error
This commit is contained in:
parent
384d401af0
commit
87df587f5a
@ -320,9 +320,18 @@ pub fn (p mut Parser) top_stmt() ast.Stmt {
|
||||
return p.comment()
|
||||
}
|
||||
else {
|
||||
// #printf("");
|
||||
p.error('bad top level statement ' + p.tok.str())
|
||||
return ast.Stmt{}
|
||||
if p.pref.is_script && !p.pref.is_test {
|
||||
p.scanner.text = 'fn main() {' + p.scanner.text + '}'
|
||||
p.scanner.is_started = false
|
||||
p.scanner.pos = 0
|
||||
p.next()
|
||||
p.next()
|
||||
return p.top_stmt()
|
||||
}
|
||||
else {
|
||||
p.error('bad top level statement ' + p.tok.str())
|
||||
return ast.Stmt{}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user