diff src/testdir/test_vim9_func.vim @ 22736:56907027dba7 v8.2.1916

patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used Commit: https://github.com/vim/vim/commit/171fb923b8f8da9fb0db1c8c86e35cf4e1339000 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 28 16:54:47 2020 +0100 patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used Problem: Vim9: function call is aborted even when "silent!" is used. Solution: Use did_emsg instead of called_emsg. (closes https://github.com/vim/vim/issues/7213)
author Bram Moolenaar <Bram@vim.org>
date Wed, 28 Oct 2020 17:00:03 +0100
parents 02b782e80ee4
children f7f2d73ff85e
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1462,6 +1462,35 @@ func Test_silent_echo()
   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