aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c14
-rw-r--r--src/nvim/eval/typval.c2
2 files changed, 12 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ee0860a8d1..f9b32d758d 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1467,14 +1467,22 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const
}
return NULL;
}
- if (!(lp->ll_tv->v_type == VAR_LIST && lp->ll_tv->vval.v_list != NULL)
- && !(lp->ll_tv->v_type == VAR_DICT && lp->ll_tv->vval.v_dict != NULL)
- && !(lp->ll_tv->v_type == VAR_BLOB && lp->ll_tv->vval.v_blob != NULL)) {
+ if (lp->ll_tv->v_type != VAR_LIST
+ && lp->ll_tv->v_type != VAR_DICT
+ && lp->ll_tv->v_type != VAR_BLOB) {
if (!quiet) {
emsg(_("E689: Can only index a List, Dictionary or Blob"));
}
return NULL;
}
+
+ // a NULL list/blob works like an empty list/blob, allocate one now.
+ if (lp->ll_tv->v_type == VAR_LIST && lp->ll_tv->vval.v_list == NULL) {
+ tv_list_alloc_ret(lp->ll_tv, kListLenUnknown);
+ } else if (lp->ll_tv->v_type == VAR_BLOB && lp->ll_tv->vval.v_blob == NULL) {
+ tv_blob_alloc_ret(lp->ll_tv);
+ }
+
if (lp->ll_range) {
if (!quiet) {
emsg(_("E708: [:] must come last"));
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index ea118e4bc6..9fca4adcf7 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -625,7 +625,7 @@ listitem_T *tv_list_check_range_index_one(list_T *const l, int *const n1, const
listitem_T *li = tv_list_find_index(l, n1);
if (li == NULL) {
if (!quiet) {
- semsg(_(e_list_index_out_of_range_nr), (int64_t)n1);
+ semsg(_(e_list_index_out_of_range_nr), (int64_t)(*n1));
}
return NULL;
}