mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Problem: Vim9: cannot initialize a variable to null_list. Solution: Give negative count to NEWLIST. (closes #10027) Also fix inconsistencies in comparing with null values.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user