Skip to content

Commit aea23e8

Browse files
committed
strconv: fix fxx_to_str_l_parse/fxx_to_str_l_parse_no_dot returning s without cloning
1 parent acf9d16 commit aea23e8

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

vlib/builtin/array_test.v

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,6 @@ fn test_array_int_pop() {
10921092
assert z == 4
10931093
x1 := a.pop()
10941094
x2 := a.pop()
1095-
dump(x1)
1096-
dump(x2)
10971095
final := a.pop()
10981096
assert final == 1
10991097
}

vlib/builtin/string_int_test.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn test_signed_cast() {
186186
}
187187

188188
// test g format
189-
{
189+
unsafe {
190190
mut u := strconv.Float64u{
191191
u: strconv.double_plus_zero
192192
}
@@ -202,7 +202,7 @@ fn test_signed_cast() {
202202
assert '${u.f:g}' == '-inf'
203203
assert '${u.f:G}' == '-INF'
204204
}
205-
{
205+
unsafe {
206206
mut u := strconv.Float32u{
207207
u: strconv.single_plus_zero
208208
}

vlib/strconv/utilities.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pub fn f64_to_str_l_no_dot(f f64) string {
272272
pub fn fxx_to_str_l_parse(s string) string {
273273
// check for +inf -inf Nan
274274
if s.len > 2 && (s[0] == `n` || s[1] == `i`) {
275-
return s
275+
return s.clone()
276276
}
277277

278278
m_sgn_flag := false
@@ -395,7 +395,7 @@ pub fn fxx_to_str_l_parse(s string) string {
395395
pub fn fxx_to_str_l_parse_no_dot(s string) string {
396396
// check for +inf -inf Nan
397397
if s.len > 2 && (s[0] == `n` || s[1] == `i`) {
398-
return s
398+
return s.clone()
399399
}
400400

401401
m_sgn_flag := false

0 commit comments

Comments
 (0)