Problem: Vim9: error for an autocmd defined in a :def function in legacy
Vim script.
Solution: Don't check the variable type. (closes #6758)
&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.
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1503,
/**/
1502,
/**/
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)
{