diff src/vim9type.c @ 22419:6a9e5c087c86 v8.2.1758

patch 8.2.1758: Vim9: type of unmaterialized list is wrong Commit: https://github.com/vim/vim/commit/5597ba046790e5ffd76dfc327d7898c56df65d3f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 27 17:45:03 2020 +0200 patch 8.2.1758: Vim9: type of unmaterialized list is wrong Problem: Vim9: type of unmaterialized list is wrong. Solution: Use list<number>.
author Bram Moolenaar <Bram@vim.org>
date Sun, 27 Sep 2020 18:00:03 +0200
parents 712bc35842aa
children 0e03ef68e738
line wrap: on
line diff
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -269,15 +269,17 @@ typval2type_int(typval_T *tv, garray_T *
 
     if (tv->v_type == VAR_LIST)
     {
-	listitem_T *li;
+	list_T	    *l = tv->vval.v_list;
+	listitem_T  *li;
 
-	if (tv->vval.v_list == NULL || tv->vval.v_list->lv_first == NULL)
+	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(&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)
+	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);