# HG changeset patch # User Bram Moolenaar # Date 1599321604 -7200 # Node ID 679269735ec34131d2baeea7949436bf323ed065 # Parent fbcfa658f05610117252e6ac71001c908d5ee1d8 patch 8.2.1603: Vim9: cannot use "true" with getchar() Commit: https://github.com/vim/vim/commit/c08cc72947fdfab484f53c5d9bbea662bc5a9c8f Author: Bram Moolenaar Date: Sat Sep 5 17:51:23 2020 +0200 patch 8.2.1603: Vim9: cannot use "true" with getchar() Problem: Vim9: cannot use "true" with getchar(). Solution: use tv_get_bool_chk(). (closes https://github.com/vim/vim/issues/6874) diff --git a/src/getchar.c b/src/getchar.c --- a/src/getchar.c +++ b/src/getchar.c @@ -2037,7 +2037,7 @@ f_getchar(typval_T *argvars, typval_T *r 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 --- 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 --- 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 */ /**/ + 1603, +/**/ 1602, /**/ 1601,