Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
24278:4ab4ef0c48b1 | 24279:e3dbf2e58c6a |
---|---|
3218 | 3218 |
3219 delete('Xlegacy_script.vim') | 3219 delete('Xlegacy_script.vim') |
3220 delete('Xvim9_script.vim') | 3220 delete('Xvim9_script.vim') |
3221 enddef | 3221 enddef |
3222 | 3222 |
3223 def Test_declare_script_in_func() | |
3224 var lines =<< trim END | |
3225 vim9script | |
3226 func Declare() | |
3227 let s:local = 123 | |
3228 endfunc | |
3229 Declare() | |
3230 assert_equal(123, local) | |
3231 | |
3232 var error: string | |
3233 try | |
3234 local = 'asdf' | |
3235 catch | |
3236 error = v:exception | |
3237 endtry | |
3238 assert_match('E1012: Type mismatch; expected number but got string', error) | |
3239 | |
3240 lockvar local | |
3241 try | |
3242 local = 999 | |
3243 catch | |
3244 error = v:exception | |
3245 endtry | |
3246 assert_match('E741: Value is locked: local', error) | |
3247 END | |
3248 CheckScriptSuccess(lines) | |
3249 enddef | |
3250 | |
3251 | |
3223 func Test_vim9script_not_global() | 3252 func Test_vim9script_not_global() |
3224 " check that items defined in Vim9 script are script-local, not global | 3253 " check that items defined in Vim9 script are script-local, not global |
3225 let vim9lines =<< trim END | 3254 let vim9lines =<< trim END |
3226 vim9script | 3255 vim9script |
3227 var name = 'local' | 3256 var name = 'local' |