Mercurial > vim
comparison src/list.c @ 25603:525ef4d1d412 v8.2.3338
patch 8.2.3338: Vim9: no type check when assigning a list range
Commit: https://github.com/vim/vim/commit/89071cb6a116a74f78f77a1853e6fada44872a15
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 13 18:20:09 2021 +0200
patch 8.2.3338: Vim9: no type check when assigning a list range
Problem: Vim9: no type check when assigning a list range. (Naohiro Ono)
Solution: Check the member type. (closes https://github.com/vim/vim/issues/8750)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 13 Aug 2021 18:30:03 +0200 |
parents | b85e44974a08 |
children | 9edad9a8cca6 |
comparison
equal
deleted
inserted
replaced
25602:39d590a60afb | 25603:525ef4d1d412 |
---|---|
850 listitem_T *src_li; | 850 listitem_T *src_li; |
851 listitem_T *dest_li; | 851 listitem_T *dest_li; |
852 long idx1 = idx1_arg; | 852 long idx1 = idx1_arg; |
853 listitem_T *first_li = list_find_index(dest, &idx1); | 853 listitem_T *first_li = list_find_index(dest, &idx1); |
854 long idx; | 854 long idx; |
855 type_T *member_type = NULL; | |
855 | 856 |
856 /* | 857 /* |
857 * Check whether any of the list items is locked before making any changes. | 858 * Check whether any of the list items is locked before making any changes. |
858 */ | 859 */ |
859 idx = idx1; | 860 idx = idx1; |
867 break; | 868 break; |
868 dest_li = dest_li->li_next; | 869 dest_li = dest_li->li_next; |
869 ++idx; | 870 ++idx; |
870 } | 871 } |
871 | 872 |
873 if (in_vim9script() && dest->lv_type != NULL | |
874 && dest->lv_type->tt_member != NULL) | |
875 member_type = dest->lv_type->tt_member; | |
876 | |
872 /* | 877 /* |
873 * Assign the List values to the list items. | 878 * Assign the List values to the list items. |
874 */ | 879 */ |
875 idx = idx1; | 880 idx = idx1; |
876 dest_li = first_li; | 881 dest_li = first_li; |
878 { | 883 { |
879 if (op != NULL && *op != '=') | 884 if (op != NULL && *op != '=') |
880 tv_op(&dest_li->li_tv, &src_li->li_tv, op); | 885 tv_op(&dest_li->li_tv, &src_li->li_tv, op); |
881 else | 886 else |
882 { | 887 { |
888 if (member_type != NULL | |
889 && check_typval_arg_type(member_type, &src_li->li_tv, | |
890 NULL, 0) == FAIL) | |
891 return FAIL; | |
883 clear_tv(&dest_li->li_tv); | 892 clear_tv(&dest_li->li_tv); |
884 copy_tv(&src_li->li_tv, &dest_li->li_tv); | 893 copy_tv(&src_li->li_tv, &dest_li->li_tv); |
885 } | 894 } |
886 src_li = src_li->li_next; | 895 src_li = src_li->li_next; |
887 if (src_li == NULL || (!empty_idx2 && idx2 == idx)) | 896 if (src_li == NULL || (!empty_idx2 && idx2 == idx)) |