Patch 8.2.1916
Problem:    Vim9: function call is aborted even when "silent!" is used.
Solution:   Use did_emsg instead of called_emsg. (closes #7213)
Files:      src/vim9execute.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1915/src/vim9execute.c   2020-10-26 18:46:49.480589241 +0100
--- src/vim9execute.c   2020-10-28 16:51:12.661848723 +0100
***************
*** 550,556 ****
  {
      typval_T  argvars[MAX_FUNC_ARGS];
      int               idx;
!     int               called_emsg_before = called_emsg;
      ectx_T    *prev_ectx = current_ectx;
  
      if (call_prepare(argcount, argvars, ectx) == FAIL)
--- 550,556 ----
  {
      typval_T  argvars[MAX_FUNC_ARGS];
      int               idx;
!     int               did_emsg_before = did_emsg;
      ectx_T    *prev_ectx = current_ectx;
  
      if (call_prepare(argcount, argvars, ectx) == FAIL)
***************
*** 566,572 ****
      for (idx = 0; idx < argcount; ++idx)
        clear_tv(&argvars[idx]);
  
!     if (called_emsg != called_emsg_before)
        return FAIL;
      return OK;
  }
--- 566,572 ----
      for (idx = 0; idx < argcount; ++idx)
        clear_tv(&argvars[idx]);
  
!     if (did_emsg != did_emsg_before)
        return FAIL;
      return OK;
  }
***************
*** 834,839 ****
--- 834,840 ----
      msglist_T *private_msg_list = NULL;
      cmdmod_T  save_cmdmod;
      int               restore_cmdmod = FALSE;
+     int               trylevel_at_start = trylevel;
  
  // Get pointer to item in the stack.
  #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
***************
*** 2866,2872 ****
        continue;
  
  on_error:
!       if (trylevel == 0)
            goto failed;
      }
  
--- 2867,2874 ----
        continue;
  
  on_error:
!       // If we are not inside a try-catch started here, abort execution.
!       if (trylevel <= trylevel_at_start)
            goto failed;
      }
  
*** ../vim-8.2.1915/src/testdir/test_vim9_func.vim      2020-10-28 
14:31:11.646925147 +0100
--- src/testdir/test_vim9_func.vim      2020-10-28 16:52:50.649578263 +0100
***************
*** 1462,1467 ****
--- 1462,1496 ----
    call delete('XTest_silent_echo')
  endfunc
  
+ def SilentlyError()
+   execute('silent! invalid')
+   g:did_it = 'yes'
+ enddef
+ 
+ "func UserError()
+ "  silent! invalid
+ "endfunc
+ "
+ "def SilentlyUserError()
+ "  UserError()
+ "  g:did_it = 'yes'
+ "enddef
+ 
+ " This can't be a :def function, because the assert would not be reached.
+ " And this must not be inside a try/endtry.
+ func Test_ignore_silent_error()
+   let g:did_it = 'no'
+   call SilentlyError()
+   call assert_equal('yes', g:did_it)
+ 
+ "  this doesn't work yet
+ "  let g:did_it = 'no'
+ "  call SilentlyUserError()
+ "  call assert_equal('yes', g:did_it)
+ 
+   unlet g:did_it
+ endfunc
+ 
  def Fibonacci(n: number): number
    if n < 2
      return n
*** ../vim-8.2.1915/src/version.c       2020-10-28 14:31:11.646925147 +0100
--- src/version.c       2020-10-28 16:53:30.977467674 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1916,
  /**/

-- 
Drink wet cement and get really stoned.

 /// 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/202010281555.09SFttd82181344%40masaka.moolenaar.net.

Raspunde prin e-mail lui