diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-27 17:45:03 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-27 17:45:03 +0200 |
commit | 5597ba046790e5ffd76dfc327d7898c56df65d3f (patch) | |
tree | 3b82fdb7736af0280c32831a8af39eb1bb88d7a4 | |
parent | a5fe91e6dc610bc823bc3201e2c88179989b13fb (diff) |
patch 8.2.1758: Vim9: type of unmaterialized list is wrongv8.2.1758
Problem: Vim9: type of unmaterialized list is wrong.
Solution: Use list<number>.
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 4 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9type.c | 12 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 411ed70174..fe43e80e1f 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1517,6 +1517,10 @@ def Test_expr7_list() 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) diff --git a/src/version.c b/src/version.c index 9ef77d87a0..ed7b44933e 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1758, +/**/ 1757, /**/ 1756, diff --git a/src/vim9type.c b/src/vim9type.c index c7e3dde32c..931b575b66 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -269,15 +269,17 @@ typval2type_int(typval_T *tv, garray_T *type_gap) 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); |