forked from aniani/vim
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Problem: Vim9: no error if using job_info() result wrongly. Solution: Adjust return type on number of arguments. (closes #7667)
This commit is contained in:
@@ -472,6 +472,13 @@ ret_dict_any(int argcount UNUSED, type_T **argtypes UNUSED)
|
|||||||
return &t_dict_any;
|
return &t_dict_any;
|
||||||
}
|
}
|
||||||
static type_T *
|
static type_T *
|
||||||
|
ret_job_info(int argcount, type_T **argtypes UNUSED)
|
||||||
|
{
|
||||||
|
if (argcount == 0)
|
||||||
|
return &t_list_job;
|
||||||
|
return &t_dict_any;
|
||||||
|
}
|
||||||
|
static type_T *
|
||||||
ret_dict_number(int argcount UNUSED, type_T **argtypes UNUSED)
|
ret_dict_number(int argcount UNUSED, type_T **argtypes UNUSED)
|
||||||
{
|
{
|
||||||
return &t_dict_number;
|
return &t_dict_number;
|
||||||
@@ -1100,7 +1107,7 @@ static funcentry_T global_functions[] =
|
|||||||
{"job_getchannel", 1, 1, FEARG_1, NULL,
|
{"job_getchannel", 1, 1, FEARG_1, NULL,
|
||||||
ret_channel, JOB_FUNC(f_job_getchannel)},
|
ret_channel, JOB_FUNC(f_job_getchannel)},
|
||||||
{"job_info", 0, 1, FEARG_1, NULL,
|
{"job_info", 0, 1, FEARG_1, NULL,
|
||||||
ret_dict_any, JOB_FUNC(f_job_info)},
|
ret_job_info, JOB_FUNC(f_job_info)},
|
||||||
{"job_setoptions", 2, 2, FEARG_1, NULL,
|
{"job_setoptions", 2, 2, FEARG_1, NULL,
|
||||||
ret_void, JOB_FUNC(f_job_setoptions)},
|
ret_void, JOB_FUNC(f_job_setoptions)},
|
||||||
{"job_start", 1, 2, FEARG_1, NULL,
|
{"job_start", 1, 2, FEARG_1, NULL,
|
||||||
|
@@ -433,6 +433,7 @@ EXTERN type_T t_dict_empty INIT6(VAR_DICT, 0, 0, TTFLAG_STATIC, &t_unknown, NULL
|
|||||||
EXTERN type_T t_list_bool INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_bool, NULL);
|
EXTERN type_T t_list_bool INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_bool, NULL);
|
||||||
EXTERN type_T t_list_number INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_number, NULL);
|
EXTERN type_T t_list_number INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_number, NULL);
|
||||||
EXTERN type_T t_list_string INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_string, NULL);
|
EXTERN type_T t_list_string INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_string, NULL);
|
||||||
|
EXTERN type_T t_list_job INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_job, NULL);
|
||||||
EXTERN type_T t_list_dict_any INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_dict_any, NULL);
|
EXTERN type_T t_list_dict_any INIT6(VAR_LIST, 0, 0, TTFLAG_STATIC, &t_dict_any, NULL);
|
||||||
|
|
||||||
EXTERN type_T t_dict_bool INIT6(VAR_DICT, 0, 0, TTFLAG_STATIC, &t_bool, NULL);
|
EXTERN type_T t_dict_bool INIT6(VAR_DICT, 0, 0, TTFLAG_STATIC, &t_bool, NULL);
|
||||||
|
@@ -314,6 +314,16 @@ def Test_extend_list_item_type()
|
|||||||
CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
|
CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_job_info_return_type()
|
||||||
|
if has('job')
|
||||||
|
job_start(&shell)
|
||||||
|
var jobs = job_info()
|
||||||
|
assert_equal(v:t_list, type(jobs))
|
||||||
|
assert_equal(v:t_dict, type(job_info(jobs[0])))
|
||||||
|
job_stop(jobs[0])
|
||||||
|
endif
|
||||||
|
enddef
|
||||||
|
|
||||||
def Wrong_dict_key_type(items: list<number>): list<number>
|
def Wrong_dict_key_type(items: list<number>): list<number>
|
||||||
return filter(items, (_, val) => get({[val]: 1}, 'x'))
|
return filter(items, (_, val) => get({[val]: 1}, 'x'))
|
||||||
enddef
|
enddef
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2338,
|
||||||
/**/
|
/**/
|
||||||
2337,
|
2337,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user