Skip to content

Commit a48f786

Browse files
committed
patch 8.2.1610: Vim9: cannot pass "true" to list2str() and str2list()
Problem: Vim9: cannot pass "true" to list2str() and str2list(). Solution: Use tv_get_bool_chk(). (closes #6877)
1 parent 7918238 commit a48f786

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7982,7 +7982,7 @@ f_str2list(typval_T *argvars, typval_T *rettv)
79827982
return;
79837983

79847984
if (argvars[1].v_type != VAR_UNKNOWN)
7985-
utf8 = (int)tv_get_number_chk(&argvars[1], NULL);
7985+
utf8 = (int)tv_get_bool_chk(&argvars[1], NULL);
79867986

79877987
p = tv_get_string(&argvars[0]);
79887988

src/list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ f_list2str(typval_T *argvars, typval_T *rettv)
13971397
return; // empty list results in empty string
13981398

13991399
if (argvars[1].v_type != VAR_UNKNOWN)
1400-
utf8 = (int)tv_get_number_chk(&argvars[1], NULL);
1400+
utf8 = (int)tv_get_bool_chk(&argvars[1], NULL);
14011401

14021402
CHECK_LIST_MATERIALIZE(l);
14031403
ga_init2(&ga, 1, 80);

src/testdir/test_vim9_func.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,13 @@ def Test_has()
15221522
assert_equal(1, has('eval', true))
15231523
enddef
15241524

1525+
def Test_list2str_str2list_utf8()
1526+
let s = "\u3042\u3044"
1527+
let l = [0x3042, 0x3044]
1528+
assert_equal(l, str2list(s, true))
1529+
assert_equal(s, list2str(l, true))
1530+
enddef
1531+
15251532
def Fibonacci(n: number): number
15261533
if n < 2
15271534
return n

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1610,
757759
/**/
758760
1609,
759761
/**/

0 commit comments

Comments
 (0)