mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3974: Vim9: LISTAPPEND instruction does not check for a locked list
Problem: Vim9: LISTAPPEND instruction does not check for a locked list. Solution: Check whether the list is locked. (closes #9452)
This commit is contained in:
@@ -78,6 +78,17 @@ enddef
|
|||||||
def Test_add()
|
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'])
|
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')
|
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
|
enddef
|
||||||
|
|
||||||
def Test_add_blob()
|
def Test_add_blob()
|
||||||
|
@@ -749,6 +749,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3974,
|
||||||
/**/
|
/**/
|
||||||
3973,
|
3973,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -3911,12 +3911,14 @@ exec_instructions(ectx_T *ectx)
|
|||||||
list_T *l = tv1->vval.v_list;
|
list_T *l = tv1->vval.v_list;
|
||||||
|
|
||||||
// add an item to a list
|
// add an item to a list
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
{
|
{
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
|
||||||
emsg(_(e_cannot_add_to_null_list));
|
emsg(_(e_cannot_add_to_null_list));
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
if (value_check_lock(l->lv_lock, NULL, FALSE))
|
||||||
|
goto on_error;
|
||||||
if (list_append_tv(l, tv2) == FAIL)
|
if (list_append_tv(l, tv2) == FAIL)
|
||||||
goto theend;
|
goto theend;
|
||||||
clear_tv(tv2);
|
clear_tv(tv2);
|
||||||
|
Reference in New Issue
Block a user