diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 2 | ||||
-rw-r--r-- | src/proto/typval.pro | 1 | ||||
-rw-r--r-- | src/testdir/test_vim9_func.vim | 7 | ||||
-rw-r--r-- | src/typval.c | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 22 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index c80013960..585975a80 100644 --- a/src/eval.c +++ b/src/eval.c @@ -326,7 +326,7 @@ eval_expr_to_bool(typval_T *expr, int *error) *error = TRUE; return FALSE; } - res = (tv_get_number_chk(&rettv, error) != 0); + res = (tv_get_bool_chk(&rettv, error) != 0); clear_tv(&rettv); return res; } diff --git a/src/proto/typval.pro b/src/proto/typval.pro index 15f934591..25ad3e673 100644 --- a/src/proto/typval.pro +++ b/src/proto/typval.pro @@ -7,6 +7,7 @@ void init_tv(typval_T *varp); varnumber_T tv_get_number(typval_T *varp); varnumber_T tv_get_number_chk(typval_T *varp, int *denote); varnumber_T tv_get_bool(typval_T *varp); +varnumber_T tv_get_bool_chk(typval_T *varp, int *denote); float_T tv_get_float(typval_T *varp); char_u *tv_get_string(typval_T *varp); char_u *tv_get_string_buf(typval_T *varp, char_u *buf); diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 446ee4d03..79fd80ae1 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1379,6 +1379,13 @@ func Test_silent_echo() call delete('XTest_silent_echo') endfunc +def Test_search() + new + setline(1, ['foo', 'bar']) + let val = 0 + assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1})) +enddef + def Fibonacci(n: number): number if n < 2 return n diff --git a/src/typval.c b/src/typval.c index 053f30077..2203bc6fa 100644 --- a/src/typval.c +++ b/src/typval.c @@ -270,6 +270,17 @@ tv_get_bool(typval_T *varp) } +/* + * Get the boolean value of "varp". This is like tv_get_number_chk(), + * but in Vim9 script accepts Number and Bool. + */ + varnumber_T +tv_get_bool_chk(typval_T *varp, int *denote) +{ + return tv_get_bool_or_number_chk(varp, denote, TRUE); + +} + #ifdef FEAT_FLOAT float_T tv_get_float(typval_T *varp) diff --git a/src/version.c b/src/version.c index e8eb8521d..fc6884c1e 100644 --- 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 */ /**/ + 1480, +/**/ 1479, /**/ 1478, |