diff src/testdir/test_user_func.vim @ 30108:0352577f1ba5 v9.0.0390

patch 9.0.0390: cannot use a partial with :defer Commit: https://github.com/vim/vim/commit/86d87256c4005c6215da5af2597fbf6f6304421f Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 5 21:21:25 2022 +0100 patch 9.0.0390: cannot use a partial with :defer Problem: Cannot use a partial with :defer. Solution: Add the partial arguments before the other arguments. Disallow using a dictionary.
author Bram Moolenaar <Bram@vim.org>
date Mon, 05 Sep 2022 22:30:04 +0200
parents 6cf788ab844c
children 458162398682
line wrap: on
line diff
--- a/src/testdir/test_user_func.vim
+++ b/src/testdir/test_user_func.vim
@@ -529,8 +529,11 @@ func Test_funcdef_alloc_failure()
   bw!
 endfunc
 
-func AddDefer(arg)
-  call extend(g:deferred, [a:arg])
+func AddDefer(arg1, ...)
+  call extend(g:deferred, [a:arg1])
+  if a:0 == 1
+    call extend(g:deferred, [a:1])
+  endif
 endfunc
 
 func WithDeferTwo()
@@ -550,6 +553,13 @@ func WithDeferOne()
   call extend(g:deferred, ['end One'])
 endfunc
 
+func WithPartialDefer()
+  call extend(g:deferred, ['in Partial'])
+  let Part = funcref('AddDefer', ['arg1'])
+  defer Part("arg2")
+  call extend(g:deferred, ['end Partial'])
+endfunc
+
 func Test_defer()
   let g:deferred = []
   call WithDeferOne()
@@ -558,6 +568,17 @@ func Test_defer()
   unlet g:deferred
 
   call assert_equal('', glob('Xfuncdefer'))
+
+  call assert_fails('defer delete("Xfuncdefer")->Another()', 'E488:')
+  call assert_fails('defer delete("Xfuncdefer").member', 'E488:')
+
+  let g:deferred = []
+  call WithPartialDefer()
+  call assert_equal(['in Partial', 'end Partial', 'arg1', 'arg2'], g:deferred)
+  unlet g:deferred
+
+  let Part = funcref('AddDefer', ['arg1'], {})
+  call assert_fails('defer Part("arg2")', 'E1300:')
 endfunc