0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.2.2680: Vim9: problem defining a script variable from legacy function

Problem:    Vim9: problem defining a script variable from legacy function.
Solution:   Check if the script is Vim9, not the current syntax.
            (closes #8032)
This commit is contained in:
Bram Moolenaar
2021-03-31 21:07:24 +02:00
parent dad4473f02
commit e535db86e7
5 changed files with 57 additions and 7 deletions

View File

@@ -3220,6 +3220,35 @@ def Test_source_vim9_from_legacy()
delete('Xvim9_script.vim')
enddef
def Test_declare_script_in_func()
var lines =<< trim END
vim9script
func Declare()
let s:local = 123
endfunc
Declare()
assert_equal(123, local)
var error: string
try
local = 'asdf'
catch
error = v:exception
endtry
assert_match('E1012: Type mismatch; expected number but got string', error)
lockvar local
try
local = 999
catch
error = v:exception
endtry
assert_match('E741: Value is locked: local', error)
END
CheckScriptSuccess(lines)
enddef
func Test_vim9script_not_global()
" check that items defined in Vim9 script are script-local, not global
let vim9lines =<< trim END