summaryrefslogtreecommitdiff
path: root/src/vim9script.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-04-04 14:58:06 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-04 14:58:06 +0100
commit7a411a306f90339d8686e42ac16e1ae4fc7533c5 (patch)
treedef2607a7145867c305c4d55baf955bc21649bde /src/vim9script.c
parent15f74fab653a784548d5d966644926b47ba2cfa7 (diff)
downloadvim-git-7a411a306f90339d8686e42ac16e1ae4fc7533c5.tar.gz
patch 8.2.4682: Vim9: can use :unlockvar for const variablev8.2.4682
Problem: Vim9: can use :unlockvar for const variable. (Ernie Rael) Solution: Check whether the variable is a const.
Diffstat (limited to 'src/vim9script.c')
-rw-r--r--src/vim9script.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/vim9script.c b/src/vim9script.c
index cd9ff92cd..adb01e8b9 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -956,7 +956,7 @@ update_vim9_script_var(
}
else
{
- sv = find_typval_in_script(&di->di_tv, 0);
+ sv = find_typval_in_script(&di->di_tv, 0, TRUE);
}
if (sv != NULL)
{
@@ -1053,10 +1053,11 @@ hide_script_var(scriptitem_T *si, int idx, int func_defined)
/*
* Find the script-local variable that links to "dest".
* If "sid" is zero use the current script.
+ * if "must_find" is TRUE and "dest" cannot be found report an internal error.
* Returns NULL if not found and give an internal error.
*/
svar_T *
-find_typval_in_script(typval_T *dest, scid_T sid)
+find_typval_in_script(typval_T *dest, scid_T sid, int must_find)
{
scriptitem_T *si = SCRIPT_ITEM(sid == 0 ? current_sctx.sc_sid : sid);
int idx;
@@ -1076,7 +1077,8 @@ find_typval_in_script(typval_T *dest, scid_T sid)
if (sv->sv_name != NULL && sv->sv_tv == dest)
return sv;
}
- iemsg("find_typval_in_script(): not found");
+ if (must_find)
+ iemsg("find_typval_in_script(): not found");
return NULL;
}