mirror of
https://github.com/vim/vim.git
synced 2025-10-03 05:14:07 -04:00
patch 9.0.1250: cannot use an object method with :defer
Problem: Cannot use an object method with :defer. (Ernie Rael) Solution: Find the object method and generate code to call it. (closes #11886)
This commit is contained in:
@@ -1331,5 +1331,35 @@ def Test_closure_in_class()
|
||||
v9.CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_defer_with_object()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
|
||||
class CWithEE
|
||||
def Enter()
|
||||
g:result ..= "entered/"
|
||||
enddef
|
||||
def Exit()
|
||||
g:result ..= "exited"
|
||||
enddef
|
||||
endclass
|
||||
|
||||
def With(ee: CWithEE, F: func)
|
||||
ee.Enter()
|
||||
defer ee.Exit()
|
||||
F()
|
||||
enddef
|
||||
|
||||
g:result = ''
|
||||
var obj = CWithEE.new()
|
||||
obj->With(() => {
|
||||
g:result ..= "called/"
|
||||
})
|
||||
assert_equal('entered/called/exited', g:result)
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
unlet g:result
|
||||
enddef
|
||||
|
||||
|
||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||
|
Reference in New Issue
Block a user