comparison src/testdir/test_vim9_script.vim @ 22643:71b57779177d v8.2.1870

patch 8.2.1870: Vim9: no need to keep all script variables Commit: https://github.com/vim/vim/commit/39ca4127a094d8aca6f77c01be4f3fea506d5cb7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 20 14:25:07 2020 +0200 patch 8.2.1870: Vim9: no need to keep all script variables Problem: Vim9: no need to keep all script variables. Solution: Only keep script variables when a function was defined that could use them. Fix freeing static string on exit.
author Bram Moolenaar <Bram@vim.org>
date Tue, 20 Oct 2020 14:30:04 +0200
parents 576a69fc0066
children 4c21a3a47707
comparison
equal deleted inserted replaced
22642:6869968c6587 22643:71b57779177d
292 RunVim([], [], '-S Xscript') 292 RunVim([], [], '-S Xscript')
293 assert_equal(['ok'], readfile('Xdidit')) 293 assert_equal(['ok'], readfile('Xdidit'))
294 294
295 delete('Xscript') 295 delete('Xscript')
296 delete('Xdidit') 296 delete('Xdidit')
297 enddef
298
299 def Test_block_local_vars_with_func()
300 var lines =<< trim END
301 vim9script
302 if true
303 var foo = 'foo'
304 if true
305 var bar = 'bar'
306 def Func(): list<string>
307 return [foo, bar]
308 enddef
309 endif
310 endif
311 # function is compiled here, after blocks have finished, can still access
312 # "foo" and "bar"
313 assert_equal(['foo', 'bar'], Func())
314 END
315 CheckScriptSuccess(lines)
297 enddef 316 enddef
298 317
299 func g:NoSuchFunc() 318 func g:NoSuchFunc()
300 echo 'none' 319 echo 'none'
301 endfunc 320 endfunc