diff src/list.c @ 22802:3e0f909ca1f2 v8.2.1949

patch 8.2.1949: Vim9: using extend() on null dict is silently ignored Commit: https://github.com/vim/vim/commit/348be7ed07d164970ec0004bc278e254eb0cf5bf Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 4 11:36:35 2020 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Nov 2020 11:45:06 +0100
parents 42bb78d46354
children 36fc73078bce
line wrap: on
line diff
--- a/src/list.c
+++ b/src/list.c
@@ -2303,9 +2303,13 @@ f_extend(typval_T *argvars, typval_T *re
 	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 *re
 	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)