diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-21 21:55:43 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-21 21:55:43 +0200 |
commit | 81e17fbe00fd2ed93b262adc3ba41c86b02e7f46 (patch) | |
tree | abc14094da0d1a60c9131bc4b3e51bab614b3ecc | |
parent | 122616d9c1b57f1e1f29f1151f8e26d24df9092a (diff) | |
download | vim-git-81e17fbe00fd2ed93b262adc3ba41c86b02e7f46.tar.gz |
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy scriptv8.2.1503
Problem: Vim9: error for an autocmd defined in a :def function in legacy
Vim script.
Solution: Don't check the variable type. (closes #6758)
-rw-r--r-- | src/testdir/test_vim9_script.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9script.c | 4 |
3 files changed, 23 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 91867f220..5a251473c 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -3166,6 +3166,23 @@ def Test_vim9_autoload() &rtp = save_rtp enddef +def Test_script_var_in_autocmd() + # using a script variable from an autocommand, defined in a :def function in a + # legacy Vim script, cannot check the variable type. + let lines =<< trim END + let s:counter = 1 + def s:Func() + au! CursorHold + au CursorHold * s:counter += 1 + enddef + call s:Func() + doau CursorHold + call assert_equal(2, s:counter) + au! CursorHold + END + CheckScriptSuccess(lines) +enddef + def Test_cmdline_win() # if the Vim syntax highlighting uses Vim9 constructs they can be used from # the command line window. diff --git a/src/version.c b/src/version.c index 62692b82f..fe2a7ad18 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1503, +/**/ 1502, /**/ 1501, diff --git a/src/vim9script.c b/src/vim9script.c index e04c0f0c2..b9dc5d7f2 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -564,6 +564,10 @@ check_script_var_type(typval_T *dest, typval_T *value, char_u *name) scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); int idx; + if (si->sn_version != SCRIPT_VERSION_VIM9) + // legacy script doesn't store variable types + return OK; + // Find the svar_T in sn_var_vals. for (idx = 0; idx < si->sn_var_vals.ga_len; ++idx) { |