summaryrefslogtreecommitdiff
path: root/src/evalvars.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 058e8048f..19a0f3389 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2816,11 +2816,13 @@ eval_variable(
type = sv->sv_type;
}
- // If a list or dict variable wasn't initialized, do it now.
- // Not for global variables, they are not declared.
+ // If a list or dict variable wasn't initialized and has meaningful
+ // type, do it now. Not for global variables, they are not
+ // declared.
if (ht != &globvarht)
{
- if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL)
+ if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL
+ && type != NULL && type != &t_dict_empty)
{
tv->vval.v_dict = dict_alloc();
if (tv->vval.v_dict != NULL)
@@ -2829,7 +2831,8 @@ eval_variable(
tv->vval.v_dict->dv_type = alloc_type(type);
}
}
- else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL)
+ else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL
+ && type != NULL && type != &t_list_empty)
{
tv->vval.v_list = list_alloc();
if (tv->vval.v_list != NULL)
@@ -2838,12 +2841,6 @@ eval_variable(
tv->vval.v_list->lv_type = alloc_type(type);
}
}
- else if (tv->v_type == VAR_BLOB && tv->vval.v_blob == NULL)
- {
- tv->vval.v_blob = blob_alloc();
- if (tv->vval.v_blob != NULL)
- ++tv->vval.v_blob->bv_refcount;
- }
}
copy_tv(tv, rettv);
}