diff --git a/0.3_roadmap.txt b/0.3_roadmap.txt index d15048ddc7..243dba4af7 100644 --- a/0.3_roadmap.txt +++ b/0.3_roadmap.txt @@ -20,3 +20,4 @@ - method expressions with an explicit receiver as the first argument - fix all remaining generics issues (`foo(5)` instead of `foo(5)` etc) - merge v.c and v_win.c +- more advanced errors, not just `error('message')` diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 638c490ea7..363fa69684 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -1361,6 +1361,13 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) { g.writeln('); // free str on re-assignment') } } + // Autofree tmp arg vars + first_right := assign_stmt.right[0] + af := g.pref.autofree && first_right is ast.CallExpr && !g.is_builtin_mod + if af { + g.autofree_call_pregen(first_right as ast.CallExpr) + } + // // Handle optionals. We need to declare a temp variable for them, that's why they are handled // here, not in call_expr(). // `pos := s.index('x') or { return }` @@ -1388,13 +1395,6 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) { // return } } - // Autofree tmp arg vars - first_right := assign_stmt.right[0] - af := g.pref.autofree && first_right is ast.CallExpr && !g.is_builtin_mod - if af { - g.autofree_call_pregen(first_right as ast.CallExpr) - } - // // json_test failed w/o this check if return_type != table.void_type && return_type != 0 { sym := g.table.get_type_symbol(return_type) diff --git a/vlib/v/tests/valgrind/1.strings_and_arrays.v b/vlib/v/tests/valgrind/1.strings_and_arrays.v index 0fed5e83e3..af016cc047 100644 --- a/vlib/v/tests/valgrind/1.strings_and_arrays.v +++ b/vlib/v/tests/valgrind/1.strings_and_arrays.v @@ -91,7 +91,6 @@ fn opt(s string) ?int { return 1 } -/* fn optional_str() { q := 'select' s := 'query: select' @@ -109,7 +108,7 @@ fn optional_str() { } println(pos + 1) } -*/ + fn tt() { // time.parse_rfc2822('1234') }