diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-07-12 17:07:05 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-07-12 17:07:05 +0200 |
commit | eb6880b6eb7c4631f6103575c0d1336b149348c1 (patch) | |
tree | 3ef9e464dfa615794f921e78f14fa6c14fa9a944 /src/evalvars.c | |
parent | 8af81d656a4c501611f6211b6379ea9dd650c545 (diff) | |
download | vim-git-eb6880b6eb7c4631f6103575c0d1336b149348c1.tar.gz |
patch 8.2.1190: Vim9: checking for Vim9 syntax is spread outv8.2.1190
Problem: Vim9: checking for Vim9 syntax is spread out.
Solution: Use in_vim9script().
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 6e67206dc..197a19dd1 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -729,7 +729,7 @@ ex_let(exarg_T *eap) 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 @@ skip_var_one(char_u *arg, int include_type) 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 @@ ex_let_one( 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 @@ do_unlet(char_u *name, int forceit) 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 @@ eval_variable( *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 @@ find_var_ht(char_u *name, char_u **varname) 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 @@ set_var_const( } 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 @@ set_var_const( 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 @@ set_var_const( 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); |