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 a8778e0..4f5ea46 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -2037,7 +2037,7 @@
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 7303db9..3453f44 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1505,6 +1505,10 @@
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 9a58f11..7ce5eb2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1603,
+/**/
1602,
/**/
1601,