cgen: fix missing defer in fn main()

pull/4359/head
krischerven 2020-04-11 19:38:14 -04:00 committed by GitHub
parent 0f19f9dd51
commit 1abdf2d68f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -885,11 +885,13 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) {
if g.is_test { if g.is_test {
verror('test files cannot have function `main`') verror('test files cannot have function `main`')
} }
g.writeln('\treturn 0;')
} }
if g.defer_stmts.len > 0 { if g.defer_stmts.len > 0 {
g.write_defer_stmts() g.write_defer_stmts()
} }
if is_main {
g.writeln('\treturn 0;')
}
g.writeln('}') g.writeln('}')
g.defer_stmts = [] g.defer_stmts = []
g.fn_decl = 0 g.fn_decl = 0