Skip to content

Commit

Permalink
patch 8.2.3401: Vim9: cannot use negative count with finddir() and fi…
Browse files Browse the repository at this point in the history
…ndfile()

Problem:    Vim9: cannot use a negative count with finddir() and findfile().
Solution:   Adjust the return type. (closes #8776)
  • Loading branch information
brammool committed Sep 4, 2021
1 parent 7f2dd1e commit 10c83dd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/evalfunc.c
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions src/testdir/test_vim9_builtin.vim
Expand Up @@ -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:')
Expand All @@ -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:')
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -755,6 +755,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3401,
/**/
3400,
/**/
Expand Down

0 comments on commit 10c83dd

Please sign in to comment.