0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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

@@ -2553,7 +2553,22 @@ eval_variable(
ret = FAIL;
}
else if (rettv != NULL)
{
// If a list or dict variable wasn't initialized, do it now.
if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL)
{
tv->vval.v_dict = dict_alloc();
if (tv->vval.v_dict != NULL)
++tv->vval.v_dict->dv_refcount;
}
else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL)
{
tv->vval.v_list = list_alloc();
if (tv->vval.v_list != NULL)
++tv->vval.v_list->lv_refcount;
}
copy_tv(tv, rettv);
}
}
name[len] = cc;