0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

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)
This commit is contained in:
Bram Moolenaar
2021-09-04 14:49:56 +02:00
parent 7f2dd1e90c
commit 10c83dde55
3 changed files with 18 additions and 2 deletions

View File

@@ -1354,9 +1354,9 @@ static funcentry_T global_functions[] =
{"filter", 2, 2, FEARG_1, arg2_mapfilter, {"filter", 2, 2, FEARG_1, arg2_mapfilter,
ret_first_arg, f_filter}, ret_first_arg, f_filter},
{"finddir", 1, 3, FEARG_1, arg3_string_string_number, {"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, {"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, {"flatten", 1, 2, FEARG_1, arg2_list_any_number,
ret_list_any, f_flatten}, ret_list_any, f_flatten},
{"flattennew", 1, 2, FEARG_1, arg2_list_any_number, {"flattennew", 1, 2, FEARG_1, arg2_list_any_number,

View File

@@ -1027,6 +1027,14 @@ def Test_filewritable()
enddef enddef
def Test_finddir() 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(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') CheckDefAndScriptFailure2(['finddir(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1')
CheckDefExecFailure(['echo finddir("")'], 'E1175:') CheckDefExecFailure(['echo finddir("")'], 'E1175:')
@@ -1035,6 +1043,12 @@ def Test_finddir()
enddef enddef
def Test_findfile() 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(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(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special')
CheckDefExecFailure(['findfile("")'], 'E1175:') CheckDefExecFailure(['findfile("")'], 'E1175:')

View File

@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3401,
/**/ /**/
3400, 3400,
/**/ /**/