diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 0a0e3f7b06..1feb5dc600 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -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) } diff --git a/vlib/v/tests/valgrind/1.strings_and_arrays.v b/vlib/v/tests/valgrind/1.strings_and_arrays.v index f91305f748..13cec6eb18 100644 --- a/vlib/v/tests/valgrind/1.strings_and_arrays.v +++ b/vlib/v/tests/valgrind/1.strings_and_arrays.v @@ -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()