autofree: fix and test var declarations
parent
1123b8259a
commit
7d65e4cb10
|
@ -1388,6 +1388,12 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
|
||||||
// return
|
// 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
|
// json_test failed w/o this check
|
||||||
if return_type != table.void_type && return_type != 0 {
|
if return_type != table.void_type && return_type != 0 {
|
||||||
|
|
|
@ -46,6 +46,11 @@ fn str_tmp_expr_advanced() {
|
||||||
handle_strings('c' + 'd', add_strings('e' + 'f', 'g')) // both lvl 1 and lvl2 exprs must be freed
|
handle_strings('c' + 'd', add_strings('e' + 'f', 'g')) // both lvl 1 and lvl2 exprs must be freed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn str_tmp_expr_advanced_var_decl() {
|
||||||
|
a := handle_strings('c' + 'd', add_strings('e' + 'f', 'g')) // both lvl 1 and lvl2 exprs must be freed
|
||||||
|
println(a)
|
||||||
|
}
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
a int
|
a int
|
||||||
b string
|
b string
|
||||||
|
@ -114,6 +119,7 @@ fn main() {
|
||||||
foo()
|
foo()
|
||||||
str_tmp_expr()
|
str_tmp_expr()
|
||||||
str_tmp_expr_advanced()
|
str_tmp_expr_advanced()
|
||||||
|
str_tmp_expr_advanced_var_decl()
|
||||||
str_inter()
|
str_inter()
|
||||||
match_expr()
|
match_expr()
|
||||||
reassign_str()
|
reassign_str()
|
||||||
|
|
Loading…
Reference in New Issue