1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests/valgrind: vfmt fn_with_return_should_free_local_vars.vv

This commit is contained in:
Delyan Angelov 2020-08-16 13:22:32 +03:00
parent fbe02c5ae1
commit 191c908f3a

View File

@ -1,19 +1,21 @@
fn many_strings() []string { fn many_strings() []string {
mut res := []string{} mut res := []string{}
for i in 0..10000 { res << '${i:05}' } for i in 0 .. 10000 {
return res res << '${i:05}'
}
return res
} }
fn abc() int { fn abc() int {
x := many_strings() x := many_strings()
n := x.len n := x.len
// NB: the local `x` is no longer used // NB: the local `x` is no longer used
// it should be freed *before* the return // it should be freed *before* the return
return n return n
} }
fn main() { fn main() {
for i in 0..5 { for i in 0 .. 5 {
nstrings := abc() nstrings := abc()
eprintln('nstrings ${i:10}: $nstrings') eprintln('nstrings ${i:10}: $nstrings')
} }