autofree: test returning optionals
parent
b8935551f1
commit
27f5c35bde
|
@ -3619,7 +3619,7 @@ fn (mut g Gen) expr(node ast.Expr) {
|
|||
g.error('unknown type `$sym.name`', node.pos)
|
||||
}
|
||||
styp := g.typ(node_typ)
|
||||
g.write('/*SizeOf*/ sizeof(${util.no_dots(styp)})')
|
||||
g.write('sizeof(${util.no_dots(styp)})')
|
||||
}
|
||||
ast.IsRefType {
|
||||
typ := if node.typ == g.field_data_type { g.comp_for_field_value.typ } else { node.typ }
|
||||
|
|
|
@ -25,6 +25,15 @@ fn return_array(array_arg []string) []int { // array argument must not be freed
|
|||
return s
|
||||
}
|
||||
|
||||
fn return_option(array_arg []string) ?Foo { // array argument must not be freed
|
||||
s := get_foo() ? // escaping option must not be freed
|
||||
return s
|
||||
}
|
||||
|
||||
fn get_foo() ?Foo {
|
||||
return Foo{}
|
||||
}
|
||||
|
||||
fn handle_strings(s string, p string) int {
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue