mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1136: Vim9: return type of argv() is always any
Problem: Vim9: return type of argv() is always any. Solution: Use list<string> if there is no argument.
This commit is contained in:
@@ -371,6 +371,17 @@ ret_list_or_dict_1(int argcount, type_T **argtypes UNUSED)
|
||||
return &t_list_dict_any;
|
||||
}
|
||||
|
||||
static type_T *
|
||||
ret_argv(int argcount, type_T **argtypes UNUSED)
|
||||
{
|
||||
// argv() returns list of strings
|
||||
if (argcount == 0)
|
||||
return &t_list_string;
|
||||
|
||||
// argv(0) returns a string, but argv(-1] returns a list
|
||||
return &t_any;
|
||||
}
|
||||
|
||||
static type_T *ret_f_function(int argcount, type_T **argtypes);
|
||||
|
||||
/*
|
||||
@@ -448,7 +459,7 @@ static funcentry_T global_functions[] =
|
||||
{"argc", 0, 1, 0, ret_number, f_argc},
|
||||
{"argidx", 0, 0, 0, ret_number, f_argidx},
|
||||
{"arglistid", 0, 2, 0, ret_number, f_arglistid},
|
||||
{"argv", 0, 2, 0, ret_any, f_argv},
|
||||
{"argv", 0, 2, 0, ret_argv, f_argv},
|
||||
{"asin", 1, 1, FEARG_1, ret_float, FLOAT_FUNC(f_asin)},
|
||||
{"assert_beeps", 1, 2, FEARG_1, ret_number, f_assert_beeps},
|
||||
{"assert_equal", 2, 3, FEARG_2, ret_number, f_assert_equal},
|
||||
|
@@ -610,6 +610,15 @@ def Test_repeat_return_type()
|
||||
assert_equal(6, res)
|
||||
enddef
|
||||
|
||||
def Test_argv_return_type()
|
||||
next fileone filetwo
|
||||
let res = ''
|
||||
for name in argv()
|
||||
res ..= name
|
||||
endfor
|
||||
assert_equal('fileonefiletwo', res)
|
||||
enddef
|
||||
|
||||
def Test_func_type_part()
|
||||
let RefVoid: func: void
|
||||
RefVoid = FuncNoArgNoRet
|
||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1136,
|
||||
/**/
|
||||
1135,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user