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

v.parser: fix -autofree for script mode programs that do not have explicit fn main(){}

This commit is contained in:
Delyan Angelov
2021-05-24 14:42:00 +03:00
parent ce7f78522d
commit 13d1d28db1
5 changed files with 21 additions and 0 deletions

View File

@@ -575,10 +575,12 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
else {
p.inside_fn = true
if p.pref.is_script && !p.pref.is_test {
p.open_scope()
mut stmts := []ast.Stmt{}
for p.tok.kind != .eof {
stmts << p.stmt(false)
}
p.close_scope()
return ast.FnDecl{
name: 'main.main'
mod: 'main'