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

builtin: clone the strings correctly in array.push

This commit is contained in:
Alexander Medvednikov
2020-11-22 13:22:42 +01:00
parent ed7413ee51
commit f8827c3fe5
3 changed files with 21 additions and 2 deletions

View File

@ -1032,6 +1032,17 @@ fn test_direct_array_access_via_ptr() {
}
}
fn test_push_arr_string_free() {
mut lines := ['hi']
s := 'a' + 'b'
lines << s
s.free() // make sure the data in the array is valid after freeing the string
println(lines)
assert lines.len == 2
assert lines[0] == 'hi'
assert lines[1] == 'ab'
}
const (
grid_size_1 = 2
grid_size_2 = 3