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:
17
src/job.c
17
src/job.c
@@ -1894,12 +1894,21 @@ f_job_start(typval_T *argvars, typval_T *rettv)
|
|||||||
void
|
void
|
||||||
f_job_status(typval_T *argvars, typval_T *rettv)
|
f_job_status(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
job_T *job = get_job_arg(&argvars[0]);
|
if (argvars[0].v_type == VAR_JOB && argvars[0].vval.v_job == NULL)
|
||||||
|
|
||||||
if (job != NULL)
|
|
||||||
{
|
{
|
||||||
|
// A job that never started returns "fail".
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
|
rettv->vval.v_string = vim_strsave((char_u *)"fail");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
job_T *job = get_job_arg(&argvars[0]);
|
||||||
|
|
||||||
|
if (job != NULL)
|
||||||
|
{
|
||||||
|
rettv->v_type = VAR_STRING;
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -74,7 +74,11 @@ def Test_assignment()
|
|||||||
|
|
||||||
if has('channel')
|
if has('channel')
|
||||||
var chan1: channel
|
var chan1: channel
|
||||||
|
assert_equal('fail', ch_status(chan1))
|
||||||
|
|
||||||
var job1: job
|
var job1: job
|
||||||
|
assert_equal('fail', job_status(job1))
|
||||||
|
|
||||||
# calling job_start() is in test_vim9_fails.vim, it causes leak reports
|
# calling job_start() is in test_vim9_fails.vim, it causes leak reports
|
||||||
endif
|
endif
|
||||||
if has('float')
|
if has('float')
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1857,
|
||||||
/**/
|
/**/
|
||||||
1856,
|
1856,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user