0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.2193: Vim9: can change constant in :def function

Problem:    Vim9: can change constant in :def function.
Solution:   Check if a variable is locked. (issue #7526)
This commit is contained in:
Bram Moolenaar
2020-12-22 20:35:40 +01:00
parent e5492609b3
commit 3bdc90b7df
5 changed files with 39 additions and 10 deletions

View File

@@ -1693,8 +1693,10 @@ call_def_function(
case ISN_STOREW:
case ISN_STORET:
{
dictitem_T *di;
hashtab_T *ht;
dictitem_T *di;
hashtab_T *ht;
char_u *name = iptr->isn_arg.string + 2;
switch (iptr->isn_type)
{
case ISN_STOREG:
@@ -1714,11 +1716,14 @@ call_def_function(
}
--ectx.ec_stack.ga_len;
di = find_var_in_ht(ht, 0, iptr->isn_arg.string + 2, TRUE);
di = find_var_in_ht(ht, 0, name, TRUE);
if (di == NULL)
store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
else
{
SOURCING_LNUM = iptr->isn_lnum;
if (var_check_permission(di, name) == FAIL)
goto on_error;
clear_tv(&di->di_tv);
di->di_tv = *STACK_TV_BOT(0);
}