Mercurial > vim
diff src/testdir/test_vim9_script.vim @ 24279:e3dbf2e58c6a v8.2.2680
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Commit: https://github.com/vim/vim/commit/e535db86e76db5e8fcd2fa8ad54050e171e8adc3
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 31 21:07:24 2021 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 31 Mar 2021 21:15:03 +0200 |
parents | 7ffc795288dd |
children | bcfff560e089 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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