diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-13 18:20:09 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-13 18:20:09 +0200 |
commit | 89071cb6a116a74f78f77a1853e6fada44872a15 (patch) | |
tree | 79452d2bc9fd1ceb705e943090fc71fd27b7499c /src/list.c | |
parent | 069f90852f1444cac50491c10dfbd339a3f9e0c8 (diff) | |
download | vim-git-89071cb6a116a74f78f77a1853e6fada44872a15.tar.gz |
patch 8.2.3338: Vim9: no type check when assigning a list rangev8.2.3338
Problem: Vim9: no type check when assigning a list range. (Naohiro Ono)
Solution: Check the member type. (closes #8750)
Diffstat (limited to 'src/list.c')
-rw-r--r-- | src/list.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/list.c b/src/list.c index 04ddbfca1..76101bac5 100644 --- a/src/list.c +++ b/src/list.c @@ -852,6 +852,7 @@ list_assign_range( long idx1 = idx1_arg; listitem_T *first_li = list_find_index(dest, &idx1); long idx; + type_T *member_type = NULL; /* * Check whether any of the list items is locked before making any changes. @@ -869,6 +870,10 @@ list_assign_range( ++idx; } + if (in_vim9script() && dest->lv_type != NULL + && dest->lv_type->tt_member != NULL) + member_type = dest->lv_type->tt_member; + /* * Assign the List values to the list items. */ @@ -880,6 +885,10 @@ list_assign_range( tv_op(&dest_li->li_tv, &src_li->li_tv, op); else { + if (member_type != NULL + && check_typval_arg_type(member_type, &src_li->li_tv, + NULL, 0) == FAIL) + return FAIL; clear_tv(&dest_li->li_tv); copy_tv(&src_li->li_tv, &dest_li->li_tv); } |