diff src/testdir/test_user_func.vim @ 30140:3b42bdfff7cb v9.0.0406

patch 9.0.0406: deferred functions not invoked when partial func exits Commit: https://github.com/vim/vim/commit/9667b2c888351b04751bdb43cba0d4ffc8c13ab1 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 7 17:28:09 2022 +0100 patch 9.0.0406: deferred functions not invoked when partial func exits Problem: Deferred functions not invoked when partial func exits. Solution: Create a funccall_T when calling a :def function.
author Bram Moolenaar <Bram@vim.org>
date Wed, 07 Sep 2022 18:30:03 +0200
parents 6575d0bf6061
children d1c04b4dc60d
line wrap: on
line diff
--- a/src/testdir/test_user_func.vim
+++ b/src/testdir/test_user_func.vim
@@ -625,6 +625,29 @@ func Test_defer_quitall()
   call assert_false(filereadable('XQuitallTwo'))
 endfunc
 
+func Test_defer_quitall_in_expr_func()
+  let lines =<< trim END
+      def DefIndex(idx: number, val: string): bool
+        call writefile([idx .. ': ' .. val], 'Xentry' .. idx, 'D')
+        if val == 'b'
+          qa!
+        endif
+        return val == 'c'
+      enddef
+
+      def Test_defer_in_funcref()
+        assert_equal(2, indexof(['a', 'b', 'c'], funcref('g:DefIndex')))
+      enddef
+      call Test_defer_in_funcref()
+  END
+  call writefile(lines, 'XdeferQuitallExpr', 'D')
+  let res = system(GetVimCommandClean() .. ' -X -S XdeferQuitallExpr')
+  call assert_equal(0, v:shell_error)
+  call assert_false(filereadable('Xentry0'))
+  call assert_false(filereadable('Xentry1'))
+  call assert_false(filereadable('Xentry2'))
+endfunc
+
 func FuncIndex(idx, val)
   call writefile([a:idx .. ': ' .. a:val], 'Xentry' .. a:idx, 'D')
   return a:val == 'c'