0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.2.4642: Vim9: in :def function script var cannot be null

Problem:    Vim9: in :def function script var cannot be null.
Solution:   Only initialize a script variable when not set to a null value.
            (closes #10034)
This commit is contained in:
Bram Moolenaar
2022-03-28 15:22:35 +01:00
parent 471b3aed3e
commit 859cc21c6b
8 changed files with 119 additions and 7 deletions

View File

@@ -2823,7 +2823,7 @@ eval_variable(
{
if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL
&& ((type != NULL && type != &t_dict_empty)
|| !in_vim9script()))
|| !in_vim9script()))
{
tv->vval.v_dict = dict_alloc();
if (tv->vval.v_dict != NULL)
@@ -2843,6 +2843,14 @@ eval_variable(
tv->vval.v_list->lv_type = alloc_type(type);
}
}
else if (tv->v_type == VAR_BLOB && tv->vval.v_blob == NULL
&& ((type != NULL && type != &t_blob_null)
|| !in_vim9script()))
{
tv->vval.v_blob = blob_alloc();
if (tv->vval.v_blob != NULL)
++tv->vval.v_blob->bv_refcount;
}
}
copy_tv(tv, rettv);
}