]> granicus.if.org Git - vim/commitdiff
patch 8.2.3401: Vim9: cannot use negative count with finddir() and findfile() v8.2.3401
authorBram Moolenaar <Bram@vim.org>
Sat, 4 Sep 2021 12:49:56 +0000 (14:49 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 Sep 2021 12:49:56 +0000 (14:49 +0200)
Problem:    Vim9: cannot use a negative count with finddir() and findfile().
Solution:   Adjust the return type. (closes #8776)

src/evalfunc.c
src/testdir/test_vim9_builtin.vim
src/version.c

index fd385fea37744e8d3dd9cd1d558eec3fa8750de4..b3f69c1f3b8352a818ce913aa70040b495302a4c 100644 (file)
@@ -1354,9 +1354,9 @@ static funcentry_T global_functions[] =
     {"filter",         2, 2, FEARG_1,      arg2_mapfilter,
                        ret_first_arg,      f_filter},
     {"finddir",                1, 3, FEARG_1,      arg3_string_string_number,
-                       ret_string,         f_finddir},
+                       ret_any,            f_finddir},
     {"findfile",       1, 3, FEARG_1,      arg3_string_string_number,
-                       ret_string,         f_findfile},
+                       ret_any,            f_findfile},
     {"flatten",                1, 2, FEARG_1,      arg2_list_any_number,
                        ret_list_any,       f_flatten},
     {"flattennew",     1, 2, FEARG_1,      arg2_list_any_number,
index c166a43a6b464551a313568a8f338c86a2359971..d39a5e22ecbe059dcdaaaf2785f44a0fca2c9a14 100644 (file)
@@ -1027,6 +1027,14 @@ def Test_filewritable()
 enddef
 
 def Test_finddir()
+  mkdir('Xtestdir')
+  finddir('Xtestdir', '**', -1)->assert_equal(['Xtestdir'])
+  var lines =<< trim END
+      var l: list<string> = finddir('nothing', '*;', -1)
+  END
+  CheckDefAndScriptSuccess(lines)
+  delete('Xtestdir', 'rf')
+
   CheckDefAndScriptFailure2(['finddir(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1')
   CheckDefAndScriptFailure2(['finddir(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1')
   CheckDefExecFailure(['echo finddir("")'], 'E1175:')
@@ -1035,6 +1043,12 @@ def Test_finddir()
 enddef
 
 def Test_findfile()
+  findfile('runtest.vim', '**', -1)->assert_equal(['runtest.vim'])
+  var lines =<< trim END
+      var l: list<string> = findfile('nothing', '*;', -1)
+  END
+  CheckDefAndScriptSuccess(lines)
+
   CheckDefExecFailure(['findfile(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool')
   CheckDefExecFailure(['findfile(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special')
   CheckDefExecFailure(['findfile("")'], 'E1175:')
index 7482d3f7fdb79d315c130b4ed0e9680a49c41bd6..8f502cc9c63d3cbaae9820c34d116f6ecaf7eb84 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3401,
 /**/
     3400,
 /**/