# HG changeset patch # User Bram Moolenaar # Date 1599242404 -7200 # Node ID 79dd6062d15cc5d995118fbc2044be7f716760cf # Parent d51d59ea5d5646d002ae84fe43a5b172c0cf4025 patch 8.2.1592: Vim9: passing "true" to char2nr() fails Commit: https://github.com/vim/vim/commit/24f7750ffa9730579736d779b7cc94faff325fc1 Author: Bram Moolenaar Date: Fri Sep 4 19:50:57 2020 +0200 patch 8.2.1592: Vim9: passing "true" to char2nr() fails Problem: Vim9: passing "true" to char2nr() fails. Solution: Use tv_get_bool_chk(). (closes https://github.com/vim/vim/issues/6865) diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1710,7 +1710,7 @@ f_char2nr(typval_T *argvars, typval_T *r int utf8 = 0; if (argvars[1].v_type != VAR_UNKNOWN) - utf8 = (int)tv_get_number_chk(&argvars[1], NULL); + utf8 = (int)tv_get_bool_chk(&argvars[1], NULL); if (utf8) rettv->vval.v_number = utf_ptr2char(tv_get_string(&argvars[0])); diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1339,6 +1339,10 @@ def Test_col() assert_equal(5, col([1, '$'])) enddef +def Test_char2nr() + assert_equal(12354, char2nr('あ', true)) +enddef + def Test_getreg_return_type() let s1: string = getreg('"') let s2: string = getreg('"', 1) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1592, +/**/ 1591, /**/ 1590,