diff options
-rw-r--r-- | src/nvim/eval.c | 7 | ||||
-rw-r--r-- | src/nvim/eval/executor.c | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 247948ffe9..b084328f77 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1519,7 +1519,14 @@ static char *get_lval_subscript(lval_T *lp, char *p, char *name, typval_T *rettv key = (char *)tv_get_string(&var1); // is number or string } lp->ll_list = NULL; + + // a NULL dict is equivalent with an empty dict + if (lp->ll_tv->vval.v_dict == NULL) { + lp->ll_tv->vval.v_dict = tv_dict_alloc(); + lp->ll_tv->vval.v_dict->dv_refcount++; + } lp->ll_dict = lp->ll_tv->vval.v_dict; + lp->ll_di = tv_dict_find(lp->ll_dict, key, len); // When assigning to a scope dictionary check that a function and diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c index 3255e78d09..4f83eaa173 100644 --- a/src/nvim/eval/executor.c +++ b/src/nvim/eval/executor.c @@ -59,8 +59,13 @@ int eexe_mod_op(typval_T *const tv1, const typval_T *const tv2, const char *cons break; } // List += List - if (tv1->vval.v_list != NULL && tv2->vval.v_list != NULL) { - tv_list_extend(tv1->vval.v_list, tv2->vval.v_list, NULL); + if (tv2->vval.v_list != NULL) { + if (tv1->vval.v_list == NULL) { + tv1->vval.v_list = tv2->vval.v_list; + tv_list_ref(tv1->vval.v_list); + } else { + tv_list_extend(tv1->vval.v_list, tv2->vval.v_list, NULL); + } } return OK; case VAR_NUMBER: |