Skip to content

Commit 7d69970

Browse files
committed
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.
1 parent 32a23ac commit 7d69970

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/testdir/test_vim9_script.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,6 +3039,42 @@ def Test_source_vim9_from_legacy()
30393039
delete('Xvim9_script.vim')
30403040
enddef
30413041

3042+
func Test_vim9script_not_global()
3043+
" check that items defined in Vim9 script are script-local, not global
3044+
let vim9lines =<< trim END
3045+
vim9script
3046+
let var = 'local'
3047+
func TheFunc()
3048+
echo 'local'
3049+
endfunc
3050+
def DefFunc()
3051+
echo 'local'
3052+
enddef
3053+
END
3054+
call writefile(vim9lines, 'Xvim9script.vim')
3055+
source Xvim9script.vim
3056+
try
3057+
echo g:var
3058+
assert_report('did not fail')
3059+
catch /E121:/
3060+
" caught
3061+
endtry
3062+
try
3063+
call TheFunc()
3064+
assert_report('did not fail')
3065+
catch /E117:/
3066+
" caught
3067+
endtry
3068+
try
3069+
call DefFunc()
3070+
assert_report('did not fail')
3071+
catch /E117:/
3072+
" caught
3073+
endtry
3074+
3075+
call delete('Xvim9script.vium')
3076+
endfunc
3077+
30423078
def Test_vim9_copen()
30433079
# this was giving an error for setting w:quickfix_title
30443080
copen

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1450,
757759
/**/
758760
1449,
759761
/**/

0 commit comments

Comments
 (0)