To: vim_dev@googlegroups.com Subject: Patch 8.2.1758 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1758 Problem: Vim9: type of unmaterialized list is wrong. Solution: Use list. Files: src/vim9type.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1757/src/vim9type.c 2020-09-21 21:48:17.473692198 +0200 --- src/vim9type.c 2020-09-27 17:42:38.122201931 +0200 *************** *** 269,283 **** if (tv->v_type == VAR_LIST) { ! listitem_T *li; ! if (tv->vval.v_list == NULL || tv->vval.v_list->lv_first == NULL) return &t_list_empty; // Use the common type of all members. ! member_type = typval2type(&tv->vval.v_list->lv_first->li_tv, type_gap); ! for (li = tv->vval.v_list->lv_first->li_next; li != NULL; ! li = li->li_next) common_type(typval2type(&li->li_tv, type_gap), member_type, &member_type, type_gap); return get_list_type(member_type, type_gap); --- 269,285 ---- if (tv->v_type == VAR_LIST) { ! list_T *l = tv->vval.v_list; ! listitem_T *li; ! if (l == NULL || l->lv_first == NULL) return &t_list_empty; + if (l->lv_first == &range_list_item) + return &t_list_number; // Use the common type of all members. ! member_type = typval2type(&l->lv_first->li_tv, type_gap); ! for (li = l->lv_first->li_next; li != NULL; li = li->li_next) common_type(typval2type(&li->li_tv, type_gap), member_type, &member_type, type_gap); return get_list_type(member_type, type_gap); *** ../vim-8.2.1757/src/testdir/test_vim9_expr.vim 2020-09-21 22:21:15.167008475 +0200 --- src/testdir/test_vim9_expr.vim 2020-09-27 17:41:51.750285562 +0200 *************** *** 1517,1522 **** --- 1517,1526 ---- llstring = [[], ['text']] llstring = [[], []] + var rangelist: list = range(3) + g:rangelist = range(3) + CheckDefExecFailure(["var x: list = g:rangelist"], 'E1012: Type mismatch; expected list but got list', 1) + CheckDefFailure(["let x = 1234[3]"], 'E1107:', 1) CheckDefExecFailure(["let x = g:anint[3]"], 'E1062:', 1) *** ../vim-8.2.1757/src/version.c 2020-09-27 16:03:11.508543016 +0200 --- src/version.c 2020-09-27 17:43:11.502139286 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1758, /**/ -- A)bort, R)etry, D)o it right this time /// Bram Moolenaar -- Bram@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 ///