From: Bram Moolenaar Date: Sat, 5 Sep 2020 15:51:23 +0000 (+0200) Subject: patch 8.2.1603: Vim9: cannot use "true" with getchar() X-Git-Tag: v8.2.1603 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c08cc72947fdfab484f53c5d9bbea662bc5a9c8f;p=vim patch 8.2.1603: Vim9: cannot use "true" with getchar() Problem: Vim9: cannot use "true" with getchar(). Solution: use tv_get_bool_chk(). (closes #6874) --- diff --git a/src/getchar.c b/src/getchar.c index a8778e0c6..4f5ea4639 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2037,7 +2037,7 @@ f_getchar(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type == VAR_UNKNOWN) // getchar(): blocking wait. n = plain_vgetc(); - else if (tv_get_number_chk(&argvars[0], &error) == 1) + else if (tv_get_bool_chk(&argvars[0], &error)) // getchar(1): only check if char avail n = vpeekc_any(); else if (error || vpeekc_any() == NUL) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 7303db997..3453f4488 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1505,6 +1505,10 @@ def Test_getbufinfo() bwipe Xtestfile1 Xtestfile2 enddef +def Test_getchar() + assert_equal(0, getchar(true)) +enddef + def Fibonacci(n: number): number if n < 2 return n diff --git a/src/version.c b/src/version.c index 9a58f113c..7ce5eb241 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1603, /**/ 1602, /**/