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)
diff --git a/src/list.c b/src/list.c
index beea6fa..af12aea 100644
--- a/src/list.c
+++ b/src/list.c
@@ -2303,9 +2303,13 @@
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 @@
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)