0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.1857: Vim9: using job_status() on an unused var gives an error

Problem:    Vim9: using job_status() on an unused var gives an error.
Solution:   Return "fail". (closes #7158)
This commit is contained in:
Bram Moolenaar
2020-10-17 18:51:52 +02:00
parent 9668cc57a1
commit 218450ad5e
3 changed files with 19 additions and 4 deletions

View File

@@ -1894,6 +1894,14 @@ f_job_start(typval_T *argvars, typval_T *rettv)
void
f_job_status(typval_T *argvars, typval_T *rettv)
{
if (argvars[0].v_type == VAR_JOB && argvars[0].vval.v_job == NULL)
{
// A job that never started returns "fail".
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave((char_u *)"fail");
}
else
{
job_T *job = get_job_arg(&argvars[0]);
if (job != NULL)
@@ -1901,6 +1909,7 @@ f_job_status(typval_T *argvars, typval_T *rettv)
rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
}
}
}
/*

View File

@@ -74,7 +74,11 @@ def Test_assignment()
if has('channel')
var chan1: channel
assert_equal('fail', ch_status(chan1))
var job1: job
assert_equal('fail', job_status(job1))
# calling job_start() is in test_vim9_fails.vim, it causes leak reports
endif
if has('float')

View File

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