autofree: free_before_break() test

pull/7005/head
Alexander Medvednikov 2020-11-28 20:23:50 +01:00
parent 321daede1d
commit cb3367d734
2 changed files with 12 additions and 1 deletions

View File

@ -1044,7 +1044,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
g.writeln('//af tmp')
// g.autofree_call_pregen(node.exprs[0] as ast.CallExpr)
}
// g.autofree_scope_vars(node.pos.pos - 1)
// g.autofree_scope_vars(node.pos.pos - 1, node.pos.line_nr, true)
g.writeln('// ast.Return free_end')
// g.write_autofree_stmts_when_needed(node)
}

View File

@ -246,6 +246,16 @@ fn free_before_return_bool() bool {
return true
}
fn free_before_break() {
s := 'a' + 'b'
for {
q := [1, 2, 3]
if true {
break
}
}
}
struct User {
name string
age int
@ -289,6 +299,7 @@ fn main() {
free_inside_opt_block()
// free_before_return()
// free_before_return_bool()
// free_before_break()
// free_map()
// loop_map()
// free_array_except_returned_element()