mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1450: Vim9: no check that script-local items don't become global
Problem: Vim9: no check that script-local items don't become global. Solution: Add a test.
This commit is contained in:
@@ -3039,6 +3039,42 @@ def Test_source_vim9_from_legacy()
|
|||||||
delete('Xvim9_script.vim')
|
delete('Xvim9_script.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
func Test_vim9script_not_global()
|
||||||
|
" check that items defined in Vim9 script are script-local, not global
|
||||||
|
let vim9lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let var = 'local'
|
||||||
|
func TheFunc()
|
||||||
|
echo 'local'
|
||||||
|
endfunc
|
||||||
|
def DefFunc()
|
||||||
|
echo 'local'
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
call writefile(vim9lines, 'Xvim9script.vim')
|
||||||
|
source Xvim9script.vim
|
||||||
|
try
|
||||||
|
echo g:var
|
||||||
|
assert_report('did not fail')
|
||||||
|
catch /E121:/
|
||||||
|
" caught
|
||||||
|
endtry
|
||||||
|
try
|
||||||
|
call TheFunc()
|
||||||
|
assert_report('did not fail')
|
||||||
|
catch /E117:/
|
||||||
|
" caught
|
||||||
|
endtry
|
||||||
|
try
|
||||||
|
call DefFunc()
|
||||||
|
assert_report('did not fail')
|
||||||
|
catch /E117:/
|
||||||
|
" caught
|
||||||
|
endtry
|
||||||
|
|
||||||
|
call delete('Xvim9script.vium')
|
||||||
|
endfunc
|
||||||
|
|
||||||
def Test_vim9_copen()
|
def Test_vim9_copen()
|
||||||
# this was giving an error for setting w:quickfix_title
|
# this was giving an error for setting w:quickfix_title
|
||||||
copen
|
copen
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1450,
|
||||||
/**/
|
/**/
|
||||||
1449,
|
1449,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user