mirror of
https://github.com/vim/vim.git
synced 2025-10-04 05:25:06 -04:00
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.
This commit is contained in:
@@ -296,6 +296,25 @@ def Test_block_local_vars()
|
||||
delete('Xdidit')
|
||||
enddef
|
||||
|
||||
def Test_block_local_vars_with_func()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
if true
|
||||
var foo = 'foo'
|
||||
if true
|
||||
var bar = 'bar'
|
||||
def Func(): list<string>
|
||||
return [foo, bar]
|
||||
enddef
|
||||
endif
|
||||
endif
|
||||
# function is compiled here, after blocks have finished, can still access
|
||||
# "foo" and "bar"
|
||||
assert_equal(['foo', 'bar'], Func())
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
func g:NoSuchFunc()
|
||||
echo 'none'
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user