summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testdir/test_vim9_builtin.vim11
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c4
3 files changed, 16 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 978ceb068..df9e8ec10 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -78,6 +78,17 @@ enddef
def Test_add()
CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<unknown>', 'E1226: List or Blob required for argument 1'])
CheckDefFailure(['add([1], "a")'], 'E1012: Type mismatch; expected number but got string')
+
+ var lines =<< trim END
+ vim9script
+ g:thelist = [1]
+ lockvar g:thelist
+ def TryChange()
+ g:thelist->add(2)
+ enddef
+ TryChange()
+ END
+ CheckScriptFailure(lines, 'E741:')
enddef
def Test_add_blob()
diff --git a/src/version.c b/src/version.c
index 1fc6dac72..12e236cac 100644
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3974,
+/**/
3973,
/**/
3972,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index a0b1fe417..81f35787c 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -3911,12 +3911,14 @@ exec_instructions(ectx_T *ectx)
list_T *l = tv1->vval.v_list;
// add an item to a list
+ SOURCING_LNUM = iptr->isn_lnum;
if (l == NULL)
{
- SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_cannot_add_to_null_list));
goto on_error;
}
+ if (value_check_lock(l->lv_lock, NULL, FALSE))
+ goto on_error;
if (list_append_tv(l, tv2) == FAIL)
goto theend;
clear_tv(tv2);