Patch 8.2.1758
Problem:    Vim9: type of unmaterialized list is wrong.
Solution:   Use list<number>.
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<number> = range(3)
+   g:rangelist = range(3)
+   CheckDefExecFailure(["var x: list<string> = g:rangelist"], 'E1012: Type 
mismatch; expected list<string> but got list<number>', 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 -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202009271545.08RFjjdt186801%40masaka.moolenaar.net.

Raspunde prin e-mail lui