Patch 8.2.2338
Problem: Vim9: no error if using job_info() result wrongly.
Solution: Adjust return type on number of arguments. (closes #7667)
Files: src/evalfunc.c, src/globals.h, src/testdir/test_vim9_builtin.vim
*** ../vim-8.2.2337/src/evalfunc.c 2021-01-12 20:23:35.778707890 +0100
--- src/evalfunc.c 2021-01-12 21:11:42.745497903 +0100
***************
*** 472,477 ****
--- 472,484 ----
return &t_dict_any;
}
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)
{
return &t_dict_number;
***************
*** 1100,1106 ****
{"job_getchannel", 1, 1, FEARG_1, NULL,
ret_channel, JOB_FUNC(f_job_getchannel)},
{"job_info", 0, 1, FEARG_1, NULL,
! ret_dict_any, JOB_FUNC(f_job_info)},
{"job_setoptions", 2, 2, FEARG_1, NULL,
ret_void, JOB_FUNC(f_job_setoptions)},
{"job_start", 1, 2, FEARG_1, NULL,
--- 1107,1113 ----
{"job_getchannel", 1, 1, FEARG_1, NULL,
ret_channel, JOB_FUNC(f_job_getchannel)},
{"job_info", 0, 1, FEARG_1, NULL,
! ret_job_info, JOB_FUNC(f_job_info)},
{"job_setoptions", 2, 2, FEARG_1, NULL,
ret_void, JOB_FUNC(f_job_setoptions)},
{"job_start", 1, 2, FEARG_1, NULL,
*** ../vim-8.2.2337/src/globals.h 2021-01-04 12:41:49.507891351 +0100
--- src/globals.h 2021-01-12 21:13:49.229118257 +0100
***************
*** 433,438 ****
--- 433,439 ----
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_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_dict_bool INIT6(VAR_DICT, 0, 0, TTFLAG_STATIC, &t_bool, NULL);
*** ../vim-8.2.2337/src/testdir/test_vim9_builtin.vim 2021-01-12
20:23:35.778707890 +0100
--- src/testdir/test_vim9_builtin.vim 2021-01-12 21:20:22.331955905 +0100
***************
*** 314,319 ****
--- 314,329 ----
CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
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>
return filter(items, (_, val) => get({[val]: 1}, 'x'))
enddef
*** ../vim-8.2.2337/src/version.c 2021-01-12 20:51:20.713167129 +0100
--- src/version.c 2021-01-12 21:12:43.601314774 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2338,
/**/
--
There are three kinds of persons: Those who can count and those who can't.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202101122024.10CKOeFH1081026%40masaka.moolenaar.net.