diff src/testdir/test_vim9_disassemble.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 0612c64a2b87
children e1a8d2040bd7
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -291,6 +291,42 @@ def Test_disassemble_call()
         res)
 enddef
 
+def s:CreateRefs()
+  let local = 'a'
+  def Append(arg: string)
+    local ..= arg
+  enddef
+  g:Append = Append
+  def Get(): string
+    return local
+  enddef
+  g:Get = Get
+enddef
+
+def Test_disassemble_closure()
+  CreateRefs()
+  let res = execute('disass g:Append')
+  assert_match('<lambda>\d.*' ..
+        'local ..= arg.*' ..
+        '\d LOADOUTER $0.*' ..
+        '\d LOAD arg\[-1\].*' ..
+        '\d CONCAT.*' ..
+        '\d STOREOUTER $0.*' ..
+        '\d PUSHNR 0.*' ..
+        '\d RETURN.*',
+        res)
+
+  res = execute('disass g:Get')
+  assert_match('<lambda>\d.*' ..
+        'return local.*' ..
+        '\d LOADOUTER $0.*' ..
+        '\d RETURN.*',
+        res)
+
+  unlet g:Append
+  unlet g:Get
+enddef
+
 
 def EchoArg(arg: string): string
   return arg