mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3782: Vim9: no error if a function shadows a script variable (#27881)
Problem: Vim9: no error if a function shadows a script variable.
Solution: Check the function doesn't shadow a variable. (closes vim/vim#9310)
052ff291d7
Omit EVAL_VAR_NO_FUNC: Vim9 script only.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
848e64322a
commit
ead3a1bd7a
@ -2294,17 +2294,27 @@ void ex_function(exarg_T *eap)
|
||||
arg = fudi.fd_newkey;
|
||||
}
|
||||
if (arg != NULL && (fudi.fd_di == NULL || !tv_is_func(fudi.fd_di->di_tv))) {
|
||||
int j = ((uint8_t)(*arg) == K_SPECIAL) ? 3 : 0;
|
||||
while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j]) : eval_isnamec(arg[j]))) {
|
||||
j++;
|
||||
char *name_base = arg;
|
||||
if ((uint8_t)(*arg) == K_SPECIAL) {
|
||||
name_base = vim_strchr(arg, '_');
|
||||
if (name_base == NULL) {
|
||||
name_base = arg + 3;
|
||||
} else {
|
||||
name_base++;
|
||||
}
|
||||
}
|
||||
if (arg[j] != NUL) {
|
||||
int i;
|
||||
for (i = 0; name_base[i] != NUL && (i == 0
|
||||
? eval_isnamec1(name_base[i])
|
||||
: eval_isnamec(name_base[i])); i++) {}
|
||||
if (name_base[i] != NUL) {
|
||||
emsg_funcname(e_invarg2, arg);
|
||||
}
|
||||
}
|
||||
// Disallow using the g: dict.
|
||||
if (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE) {
|
||||
emsg(_("E862: Cannot use g: here"));
|
||||
goto ret_free;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user