autofree: optionals fix
parent
92630a2821
commit
c463c26983
|
@ -20,3 +20,4 @@
|
|||
- method expressions with an explicit receiver as the first argument
|
||||
- fix all remaining generics issues (`foo(5)` instead of `foo<int>(5)` etc)
|
||||
- merge v.c and v_win.c
|
||||
- more advanced errors, not just `error('message')`
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue