autofree: fix stmts() free

pull/5824/head
Alexander Medvednikov 2020-07-14 14:50:51 +02:00
parent 1338e7fce2
commit 7231b467a6
1 changed files with 5 additions and 2 deletions

View File

@ -623,8 +623,11 @@ fn (mut g Gen) stmts(stmts []ast.Stmt) {
g.write(')')
}
if g.pref.autofree && stmts.len > 0 {
// g.writeln('// autofree scope')
g.autofree_scope_vars(stmts[stmts.len - 1].position().pos)
stmt := stmts[stmts.len - 1]
if stmt !is ast.FnDecl {
// g.writeln('// autofree scope')
g.autofree_scope_vars(stmt.position().pos)
}
}
}