mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.1374: Vim9: error for assigning empty list to script variable
Problem: Vim9: error for assigning empty list to script variable. Solution: Use t_unknown for empty list member. (closes #6595)
This commit is contained in:
@@ -2782,6 +2782,20 @@ def Test_let_type_check()
|
|||||||
let var: asdf
|
let var: asdf
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1010:')
|
CheckScriptFailure(lines, 'E1010:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let s:l: list<number>
|
||||||
|
s:l = []
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let s:d: dict<number>
|
||||||
|
s:d = {}
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_forward_declaration()
|
def Test_forward_declaration()
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1374,
|
||||||
/**/
|
/**/
|
||||||
1373,
|
1373,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -502,22 +502,25 @@ typval2type(typval_T *tv, garray_T *type_gap)
|
|||||||
if (tv->v_type == VAR_STRING)
|
if (tv->v_type == VAR_STRING)
|
||||||
return &t_string;
|
return &t_string;
|
||||||
|
|
||||||
if (tv->v_type == VAR_LIST
|
if (tv->v_type == VAR_LIST)
|
||||||
&& tv->vval.v_list != NULL
|
|
||||||
&& tv->vval.v_list->lv_first != NULL)
|
|
||||||
{
|
{
|
||||||
|
if (tv->vval.v_list == NULL || tv->vval.v_list->lv_first == NULL)
|
||||||
|
return &t_list_empty;
|
||||||
|
|
||||||
// Use the type of the first member, it is the most specific.
|
// Use the type of the first member, it is the most specific.
|
||||||
member_type = typval2type(&tv->vval.v_list->lv_first->li_tv, type_gap);
|
member_type = typval2type(&tv->vval.v_list->lv_first->li_tv, type_gap);
|
||||||
return get_list_type(member_type, type_gap);
|
return get_list_type(member_type, type_gap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tv->v_type == VAR_DICT
|
if (tv->v_type == VAR_DICT)
|
||||||
&& tv->vval.v_dict != NULL
|
|
||||||
&& tv->vval.v_dict->dv_hashtab.ht_used > 0)
|
|
||||||
{
|
{
|
||||||
dict_iterator_T iter;
|
dict_iterator_T iter;
|
||||||
typval_T *value;
|
typval_T *value;
|
||||||
|
|
||||||
|
if (tv->vval.v_dict == NULL
|
||||||
|
|| tv->vval.v_dict->dv_hashtab.ht_used == 0)
|
||||||
|
return &t_dict_empty;
|
||||||
|
|
||||||
// Use the type of the first value, it is the most specific.
|
// Use the type of the first value, it is the most specific.
|
||||||
dict_iterate_start(tv, &iter);
|
dict_iterate_start(tv, &iter);
|
||||||
dict_iterate_next(&iter, &value);
|
dict_iterate_next(&iter, &value);
|
||||||
|
Reference in New Issue
Block a user