diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 543bfde478..e618f597fc 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -4664,6 +4664,7 @@ fn (mut g Gen) return_statement(node ast.Return) { if optional_none || is_regular_option || node.types[0] == ast.error_type_idx { g.write('return ') g.gen_optional_error(g.fn_decl.return_type, node.exprs[0]) + // g.writeln('; /*ret1*/') g.writeln(';') return } @@ -4778,6 +4779,7 @@ fn (mut g Gen) return_statement(node ast.Return) { } } g.writeln(' }, (Option*)(&$opt_tmp), sizeof($styp));') + g.autofree_scope_vars(node.pos.pos - 1, node.pos.line_nr, true) g.writeln('return $opt_tmp;') return } diff --git a/vlib/v/tests/valgrind/1.strings_and_arrays.v b/vlib/v/tests/valgrind/1.strings_and_arrays.v index 84c94ecca5..878cfefdb9 100644 --- a/vlib/v/tests/valgrind/1.strings_and_arrays.v +++ b/vlib/v/tests/valgrind/1.strings_and_arrays.v @@ -353,6 +353,8 @@ fn parse_header0(s string) ?string { return error('missing colon in header') } words := s.split_nth(':', 2) + // x := words[0] + // return x return words[0] } @@ -386,7 +388,7 @@ fn main() { s2 := return_sb_str() // free_map() // loop_map() - // advanced_optionals() + advanced_optionals() free_array_except_returned_element() println('end') }