Patch 8.2.1374
Problem: Vim9: error for assigning empty list to script variable.
Solution: Use t_unknown for empty list member. (closes #6595)
Files: src/vim9compile.c, src/testdir/test_vim9_script.vim
*** ../vim-8.2.1373/src/vim9compile.c 2020-08-05 14:34:08.935573705 +0200
--- src/vim9compile.c 2020-08-05 14:58:41.139420597 +0200
***************
*** 502,523 ****
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)
{
// 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)
{
dict_iterator_T iter;
typval_T *value;
// Use the type of the first value, it is the most specific.
dict_iterate_start(tv, &iter);
dict_iterate_next(&iter, &value);
--- 502,526 ----
if (tv->v_type == VAR_STRING)
return &t_string;
! 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)
{
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);
*** ../vim-8.2.1373/src/testdir/test_vim9_script.vim 2020-08-05 14:34:08.935573705 +0200
--- src/testdir/test_vim9_script.vim 2020-08-05 14:57:49.635567931 +0200
***************
*** 2782,2787 ****
--- 2782,2801 ----
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()
*** ../vim-8.2.1373/src/version.c 2020-08-05 14:34:08.935573705 +0200
--- src/version.c 2020-08-05 14:55:47.159918067 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1374,
/**/
--
hundred-and-one symptoms of being an internet addict:
127. You bring your laptop and cellular phone to church.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///