From 7afa4c7e2c73372825cf8c87a17332717a4eab8d Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 23 Mar 2021 22:11:32 +0200 Subject: [PATCH] builtin: fix `["abc", "xyz"].str()` --- vlib/builtin/array.v | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 5520dc16ca..476b306e13 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -498,6 +498,7 @@ pub fn (mut a []string) free() { // str returns a string representation of the array of strings // => '["a", "b", "c"]'. +[manualfree] pub fn (a []string) str() string { mut sb := strings.new_builder(a.len * 3) sb.write_string('[') @@ -511,7 +512,9 @@ pub fn (a []string) str() string { } } sb.write_string(']') - return sb.str() + res := sb.str() + unsafe { sb.free() } + return res } // hex returns a string with the hexadecimal representation