comparison src/testdir/test_vim9_func.vim @ 20295:bc2c9ea94ec1 v8.2.0703

patch 8.2.0703: Vim9: closure cannot store value in outer context Commit: https://github.com/vim/vim/commit/b68b346e6db6d3f848e0a89905fcd7777b73c5d8 Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 6 21:06:30 2020 +0200 patch 8.2.0703: Vim9: closure cannot store value in outer context Problem: Vim9: closure cannot store value in outer context. Solution: Make storing value in outer context work. Make :disassemble accept a function reference.
author Bram Moolenaar <Bram@vim.org>
date Wed, 06 May 2020 21:15:04 +0200
parents ce1b73835822
children 98e7b880b7b1
comparison
equal deleted inserted replaced
20294:cefbaab2e368 20295:bc2c9ea94ec1
736 736
737 unlet g:UseArg 737 unlet g:UseArg
738 unlet g:UseVararg 738 unlet g:UseVararg
739 enddef 739 enddef
740 740
741 def MakeGetAndAppendRefs()
742 let local = 'a'
743
744 def Append(arg: string)
745 local ..= arg
746 enddef
747 g:Append = Append
748
749 def Get(): string
750 return local
751 enddef
752 g:Get = Get
753 enddef
754
755 def Test_closure_append_get()
756 MakeGetAndAppendRefs()
757 assert_equal('a', g:Get())
758 g:Append('-b')
759 assert_equal('a-b', g:Get())
760 g:Append('-c')
761 assert_equal('a-b-c', g:Get())
762
763 unlet g:Append
764 unlet g:Get
765 enddef
766
741 def Test_nested_closure() 767 def Test_nested_closure()
742 let local = 'text' 768 let local = 'text'
743 def Closure(arg: string): string 769 def Closure(arg: string): string
744 return local .. arg 770 return local .. arg
745 enddef 771 enddef