1
0
forked from aniani/vim

patch 8.2.1949: Vim9: using extend() on null dict is silently ignored

Problem:    Vim9: using extend() on null dict is silently ignored.
Solution:   Give an error message.  Initialize a dict variable with an empty
            dictionary. (closes #7251)
This commit is contained in:
Bram Moolenaar
2020-11-04 11:36:35 +01:00
parent 4778b4d0e1
commit 348be7ed07
5 changed files with 82 additions and 7 deletions

View File

@@ -2303,9 +2303,13 @@ f_extend(typval_T *argvars, typval_T *rettv)
int error = FALSE;
l1 = argvars[0].vval.v_list;
if (l1 == NULL)
{
emsg(_(e_cannot_extend_null_list));
return;
}
l2 = argvars[1].vval.v_list;
if (l1 != NULL && !value_check_lock(l1->lv_lock, arg_errmsg, TRUE)
&& l2 != NULL)
if (!value_check_lock(l1->lv_lock, arg_errmsg, TRUE) && l2 != NULL)
{
if (argvars[2].v_type != VAR_UNKNOWN)
{
@@ -2339,9 +2343,13 @@ f_extend(typval_T *argvars, typval_T *rettv)
int i;
d1 = argvars[0].vval.v_dict;
if (d1 == NULL)
{
emsg(_(e_cannot_extend_null_dict));
return;
}
d2 = argvars[1].vval.v_dict;
if (d1 != NULL && !value_check_lock(d1->dv_lock, arg_errmsg, TRUE)
&& d2 != NULL)
if (!value_check_lock(d1->dv_lock, arg_errmsg, TRUE) && d2 != NULL)
{
// Check the third argument.
if (argvars[2].v_type != VAR_UNKNOWN)