diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-10-28 14:15:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-28 14:15:49 +0800 |
commit | 3de2a7f6df26ceb27d465d37f78306af2a4c5119 (patch) | |
tree | d7cfe098fea11a019e21c6899a0e8e81e7a8f244 | |
parent | 685ff3ee7247c5118fd8ef1c229af60066a4fcb4 (diff) | |
parent | 3afcc48a05693738f613464607286b5684b148cd (diff) | |
download | rneovim-3de2a7f6df26ceb27d465d37f78306af2a4c5119.tar.gz rneovim-3de2a7f6df26ceb27d465d37f78306af2a4c5119.tar.bz2 rneovim-3de2a7f6df26ceb27d465d37f78306af2a4c5119.zip |
Merge pull request #20842 from zeertzjq/vim-8.2.1395
vim-patch:8.2.{1395,3407}
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/eval/typval.c | 3 | ||||
-rw-r--r-- | src/nvim/eval/vars.c | 12 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0e4dbeaea6..d6411fb15b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1444,7 +1444,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const } wrong = ((lp->ll_dict->dv_scope == VAR_DEF_SCOPE && tv_is_func(*rettv) - && !var_check_func_name((const char *)key, lp->ll_di == NULL)) + && var_wrong_func_name((const char *)key, lp->ll_di == NULL)) || !valid_varname((const char *)key)); if (len != -1) { key[len] = prevval; diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index fb601c4307..cc6c2b5d90 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1841,6 +1841,7 @@ dictitem_T *tv_dict_item_alloc_len(const char *const key, const size_t key_len) di->di_key[key_len] = NUL; di->di_flags = DI_FLAGS_ALLOC; di->di_tv.v_lock = VAR_UNLOCKED; + di->di_tv.v_type = VAR_UNKNOWN; return di; } @@ -2436,7 +2437,7 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2, const char *const action // Check the key to be valid when adding to any scope. if (d1->dv_scope == VAR_DEF_SCOPE && tv_is_func(di2->di_tv) - && !var_check_func_name((const char *)di2->di_key, di1 == NULL)) { + && var_wrong_func_name((const char *)di2->di_key, di1 == NULL)) { break; } if (!valid_varname((const char *)di2->di_key)) { diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 4d7214205d..ef6e3f02e2 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1257,7 +1257,7 @@ void set_var_const(const char *name, const size_t name_len, typval_T *const tv, v = find_var_in_scoped_ht(name, name_len, true); } - if (tv_is_func(*tv) && !var_check_func_name(name, v == NULL)) { + if (tv_is_func(*tv) && var_wrong_func_name(name, v == NULL)) { return; } @@ -1445,9 +1445,9 @@ bool var_check_fixed(const int flags, const char *name, size_t name_len) /// @param[in] name Possible function/funcref name. /// @param[in] new_var True if it is a name for a variable. /// -/// @return false in case of error, true in case of success. Also gives an +/// @return false in case of success, true in case of failure. Also gives an /// error message if appropriate. -bool var_check_func_name(const char *const name, const bool new_var) +bool var_wrong_func_name(const char *const name, const bool new_var) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { // Allow for w: b: s: and t:. @@ -1455,16 +1455,16 @@ bool var_check_func_name(const char *const name, const bool new_var) && !ASCII_ISUPPER((name[0] != NUL && name[1] == ':') ? name[2] : name[0])) { semsg(_("E704: Funcref variable name must start with a capital: %s"), name); - return false; + return true; } // Don't allow hiding a function. When "v" is not NULL we might be // assigning another function to the same var, the type is checked // below. if (new_var && function_exists(name, false)) { semsg(_("E705: Variable name conflicts with existing function: %s"), name); - return false; + return true; } - return true; + return false; } // TODO(ZyX-I): move to eval/expressions |