changeset 21871:e27555ca1093 v8.2.1485

patch 8.2.1485: Vim9: readdirex() expression doesn't accept bool Commit: https://github.com/vim/vim/commit/af8822ce085e3bd8edeb52cbb7306ddd42427d39 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 19 13:55:01 2020 +0200 patch 8.2.1485: Vim9: readdirex() expression doesn't accept bool Problem: Vim9: readdirex() expression doesn't accept bool. Solution: Accept both -1 and bool. (closes https://github.com/vim/vim/issues/6737)
author Bram Moolenaar <Bram@vim.org>
date Wed, 19 Aug 2020 14:00:04 +0200
parents e32848bb87f2
children 5ba0e37bca94
files src/filepath.c src/testdir/test_vim9_func.vim src/version.c
diffstat 3 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -1493,6 +1493,12 @@ readdirex_checkitem(void *context, void 
     if (eval_expr_typval(expr, argv, 1, &rettv) == FAIL)
 	goto theend;
 
+    // We want to use -1, but also true/false should be allowed.
+    if (rettv.v_type == VAR_SPECIAL || rettv.v_type == VAR_BOOL)
+    {
+	rettv.v_type = VAR_NUMBER;
+	rettv.vval.v_number = rettv.vval.v_number == VVAL_TRUE;
+    }
     retval = tv_get_number_chk(&rettv, &error);
     if (error)
 	retval = -1;
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1386,6 +1386,10 @@ def Test_search()
   assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1}))
 enddef
 
+def Test_readdirex()
+   eval expand('.')->readdirex({e -> e.name[0] !=# '.'})
+enddef
+
 def Fibonacci(n: number): number
   if n < 2
     return n
--- 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 */
 /**/
+    1485,
+/**/
     1484,
 /**/
     1483,