Patch 8.2.1857
Problem:    Vim9: using job_status() on an unused var gives an error.
Solution:   Return "fail". (closes #7158)
Files:      src/job.c, src/testdir/test_vim9_assign.vim


*** ../vim-8.2.1856/src/job.c   2020-09-06 18:22:47.245500821 +0200
--- src/job.c   2020-10-17 18:45:20.022282781 +0200
***************
*** 1894,1905 ****
      void
  f_job_status(typval_T *argvars, typval_T *rettv)
  {
!     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));
      }
  }
  
--- 1894,1914 ----
      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)
!       {
!           rettv->v_type = VAR_STRING;
!           rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
!       }
      }
  }
  
*** ../vim-8.2.1856/src/testdir/test_vim9_assign.vim    2020-10-16 
19:56:08.581996958 +0200
--- src/testdir/test_vim9_assign.vim    2020-10-17 18:50:25.081450028 +0200
***************
*** 74,80 ****
--- 74,84 ----
  
    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')
*** ../vim-8.2.1856/src/version.c       2020-10-17 17:39:51.821046489 +0200
--- src/version.c       2020-10-17 18:39:25.115216220 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1857,
  /**/

-- 
>From "know your smileys":
 8<}}   Glasses, big nose, beard

 /// 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/202010171652.09HGqMT9673160%40masaka.moolenaar.net.

Raspunde prin e-mail lui