Mercurial > vim
changeset 22085:79dd6062d15c v8.2.1592
patch 8.2.1592: Vim9: passing "true" to char2nr() fails
Commit: https://github.com/vim/vim/commit/24f7750ffa9730579736d779b7cc94faff325fc1
Author: Bram Moolenaar <Bram@vim.org>
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Sep 2020 20:00:04 +0200 |
parents | d51d59ea5d56 |
children | 0fbcd63c0cc2 |
files | src/evalfunc.c src/testdir/test_vim9_func.vim src/version.c |
diffstat | 3 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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]));
--- 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)