summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-23 13:38:02 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-23 13:38:02 +0200
commitea04a6e8baff2f27da7cdd54bf70a5525994f76d (patch)
treed8578e5bec3f99d462191ba6eb49f83c60211181 /src/eval.c
parentdb950e4c0318c084c31bc7b50665284f4a47c285 (diff)
patch 8.2.0619: null dict is not handled like an empty dictv8.2.0619
Problem: Null dict is not handled like an empty dict. Solution: Fix the code and add tests. (Yegappan Lakshmanan, closes #5968)
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c
index 7130620c94..c3f0de8e32 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -871,7 +871,10 @@ get_lval(
if (len != -1)
key[len] = prevval;
if (wrong)
+ {
+ clear_tv(&var1);
return NULL;
+ }
}
if (lp->ll_di == NULL)
@@ -4553,8 +4556,9 @@ echo_string_core(
case VAR_DICT:
if (tv->vval.v_dict == NULL)
{
+ // NULL dict is equivalent to empty dict.
*tofree = NULL;
- r = NULL;
+ r = (char_u *)"{}";
}
else if (copyID != 0 && tv->vval.v_dict->dv_copyID == copyID
&& tv->vval.v_dict->dv_hashtab.ht_used != 0)
@@ -4565,6 +4569,7 @@ echo_string_core(
else
{
int old_copyID = tv->vval.v_dict->dv_copyID;
+
tv->vval.v_dict->dv_copyID = copyID;
*tofree = dict2string(tv, copyID, restore_copyID);
if (restore_copyID)