Skip to content

Commit 10c83dd

Browse files
committed
patch 8.2.3401: Vim9: cannot use negative count with finddir() and findfile()
Problem: Vim9: cannot use a negative count with finddir() and findfile(). Solution: Adjust the return type. (closes #8776)
1 parent 7f2dd1e commit 10c83dd

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/evalfunc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,9 +1354,9 @@ static funcentry_T global_functions[] =
13541354
{"filter", 2, 2, FEARG_1, arg2_mapfilter,
13551355
ret_first_arg, f_filter},
13561356
{"finddir", 1, 3, FEARG_1, arg3_string_string_number,
1357-
ret_string, f_finddir},
1357+
ret_any, f_finddir},
13581358
{"findfile", 1, 3, FEARG_1, arg3_string_string_number,
1359-
ret_string, f_findfile},
1359+
ret_any, f_findfile},
13601360
{"flatten", 1, 2, FEARG_1, arg2_list_any_number,
13611361
ret_list_any, f_flatten},
13621362
{"flattennew", 1, 2, FEARG_1, arg2_list_any_number,

src/testdir/test_vim9_builtin.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,14 @@ def Test_filewritable()
10271027
enddef
10281028

10291029
def Test_finddir()
1030+
mkdir('Xtestdir')
1031+
finddir('Xtestdir', '**', -1)->assert_equal(['Xtestdir'])
1032+
var lines =<< trim END
1033+
var l: list<string> = finddir('nothing', '*;', -1)
1034+
END
1035+
CheckDefAndScriptSuccess(lines)
1036+
delete('Xtestdir', 'rf')
1037+
10301038
CheckDefAndScriptFailure2(['finddir(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1')
10311039
CheckDefAndScriptFailure2(['finddir(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1')
10321040
CheckDefExecFailure(['echo finddir("")'], 'E1175:')
@@ -1035,6 +1043,12 @@ def Test_finddir()
10351043
enddef
10361044

10371045
def Test_findfile()
1046+
findfile('runtest.vim', '**', -1)->assert_equal(['runtest.vim'])
1047+
var lines =<< trim END
1048+
var l: list<string> = findfile('nothing', '*;', -1)
1049+
END
1050+
CheckDefAndScriptSuccess(lines)
1051+
10381052
CheckDefExecFailure(['findfile(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool')
10391053
CheckDefExecFailure(['findfile(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special')
10401054
CheckDefExecFailure(['findfile("")'], 'E1175:')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3401,
758760
/**/
759761
3400,
760762
/**/

0 commit comments

Comments
 (0)