mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
vim-patch:8.2.3064: Vim9: in script cannot set item in uninitialized list (#25605)
Problem: Vim9: in script cannot set item in uninitialized list.
Solution: When a list is NULL allocate an empty one. (closes vim/vim#8461)
e65081d1b5
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -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"));
|
||||
|
Reference in New Issue
Block a user