patch 8.2.1190: Vim9: checking for Vim9 syntax is spread out
Problem: Vim9: checking for Vim9 syntax is spread out.
Solution: Use in_vim9script().
diff --git a/src/evalvars.c b/src/evalvars.c
index 6e67206..197a19d 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -729,7 +729,7 @@
emsg(_("E985: .= is not supported with script version 2"));
else if (!ends_excmd2(eap->cmd, arg))
{
- if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
+ if (in_vim9script())
{
// Vim9 declaration ":let var: type"
arg = vim9_declare_scriptvar(eap, arg);
@@ -993,7 +993,7 @@
return arg + 2;
end = find_name_end(*arg == '$' || *arg == '&' ? arg + 1 : arg,
NULL, NULL, FNE_INCL_BR | FNE_CHECK_START);
- if (include_type && current_sctx.sc_version == SCRIPT_VERSION_VIM9)
+ if (include_type && in_vim9script())
{
// "a: type" is declaring variable "a" with a type, not "a:".
if (end == arg + 2 && end[-1] == ':')
@@ -1212,8 +1212,7 @@
emsg(_("E996: Cannot lock an environment variable"));
return NULL;
}
- if (current_sctx.sc_version == SCRIPT_VERSION_VIM9
- && (flags & LET_NO_COMMAND) == 0)
+ if (in_vim9script() && (flags & LET_NO_COMMAND) == 0)
{
vim9_declare_error(arg);
return NULL;
@@ -1576,8 +1575,7 @@
dict_T *d;
dictitem_T *di;
- if (current_sctx.sc_version == SCRIPT_VERSION_VIM9
- && check_vim9_unlet(name) == FAIL)
+ if (in_vim9script() && check_vim9_unlet(name) == FAIL)
return FAIL;
ht = find_var_ht(name, &varname);
@@ -2392,8 +2390,7 @@
*dip = v;
}
- if (tv == NULL && (current_sctx.sc_version == SCRIPT_VERSION_VIM9
- || STRNCMP(name, "s:", 2) == 0))
+ if (tv == NULL && (in_vim9script() || STRNCMP(name, "s:", 2) == 0))
{
imported_T *import;
char_u *p = STRNCMP(name, "s:", 2) == 0 ? name + 2 : name;
@@ -2634,7 +2631,7 @@
return ht; // local variable
// in Vim9 script items at the script level are script-local
- if (current_sctx.sc_version == SCRIPT_VERSION_VIM9)
+ if (in_vim9script())
{
ht = get_script_local_ht();
if (ht != NULL)
@@ -2897,7 +2894,7 @@
}
is_script_local = ht == get_script_local_ht();
- if (current_sctx.sc_version == SCRIPT_VERSION_VIM9
+ if (in_vim9script()
&& !is_script_local
&& (flags & LET_NO_COMMAND) == 0
&& name[1] == ':')
@@ -2926,8 +2923,7 @@
return;
}
- if (is_script_local
- && current_sctx.sc_version == SCRIPT_VERSION_VIM9)
+ if (is_script_local && in_vim9script())
{
if ((flags & LET_NO_COMMAND) == 0)
{
@@ -3023,7 +3019,7 @@
if (flags & LET_IS_CONST)
di->di_flags |= DI_FLAGS_LOCK;
- if (is_script_local && current_sctx.sc_version == SCRIPT_VERSION_VIM9)
+ if (is_script_local && in_vim9script())
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);