let var: asdf
END
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
def Test_forward_declaration()
if (tv->v_type == VAR_STRING)
return &t_string;
- if (tv->v_type == VAR_LIST
- && tv->vval.v_list != NULL
- && tv->vval.v_list->lv_first != NULL)
+ if (tv->v_type == VAR_LIST)
{
+ 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.
member_type = typval2type(&tv->vval.v_list->lv_first->li_tv, type_gap);
return get_list_type(member_type, type_gap);
}
- if (tv->v_type == VAR_DICT
- && tv->vval.v_dict != NULL
- && tv->vval.v_dict->dv_hashtab.ht_used > 0)
+ if (tv->v_type == VAR_DICT)
{
dict_iterator_T iter;
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.
dict_iterate_start(tv, &iter);
dict_iterate_next(&iter, &value);