comparison src/vim9execute.c @ 23458:d2b1269c2c68 v8.2.2272

patch 8.2.2272: Vim9: extend() can violate the type of a variable Commit: https://github.com/vim/vim/commit/aa210a3aeccc33c6051978017959126b037f94af Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 2 15:41:03 2021 +0100 patch 8.2.2272: Vim9: extend() can violate the type of a variable Problem: Vim9: extend() can violate the type of a variable. Solution: Add the type to the dictionary or list and check items against it. (closes #7593)
author Bram Moolenaar <Bram@vim.org>
date Sat, 02 Jan 2021 15:45:04 +0100
parents 5e6a5ccf5dcb
children 49d866e9b439
comparison
equal deleted inserted replaced
23457:86b9697a8c63 23458:d2b1269c2c68
2992 goto on_error; 2992 goto on_error;
2993 } 2993 }
2994 } 2994 }
2995 break; 2995 break;
2996 2996
2997 case ISN_SETTYPE:
2998 {
2999 checktype_T *ct = &iptr->isn_arg.type;
3000
3001 tv = STACK_TV_BOT(-1);
3002 if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
3003 {
3004 free_type(tv->vval.v_dict->dv_type);
3005 tv->vval.v_dict->dv_type = alloc_type(ct->ct_type);
3006 }
3007 else if (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)
3008 {
3009 free_type(tv->vval.v_list->lv_type);
3010 tv->vval.v_list->lv_type = alloc_type(ct->ct_type);
3011 }
3012 }
3013 break;
3014
2997 case ISN_2BOOL: 3015 case ISN_2BOOL:
2998 case ISN_COND2BOOL: 3016 case ISN_COND2BOOL:
2999 { 3017 {
3000 int n; 3018 int n;
3001 int error = FALSE; 3019 int error = FALSE;
3888 } 3906 }
3889 case ISN_CHECKLEN: smsg("%4d CHECKLEN %s%d", current, 3907 case ISN_CHECKLEN: smsg("%4d CHECKLEN %s%d", current,
3890 iptr->isn_arg.checklen.cl_more_OK ? ">= " : "", 3908 iptr->isn_arg.checklen.cl_more_OK ? ">= " : "",
3891 iptr->isn_arg.checklen.cl_min_len); 3909 iptr->isn_arg.checklen.cl_min_len);
3892 break; 3910 break;
3911 case ISN_SETTYPE:
3912 {
3913 char *tofree;
3914
3915 smsg("%4d SETTYPE %s", current,
3916 type_name(iptr->isn_arg.type.ct_type, &tofree));
3917 vim_free(tofree);
3918 break;
3919 }
3893 case ISN_COND2BOOL: smsg("%4d COND2BOOL", current); break; 3920 case ISN_COND2BOOL: smsg("%4d COND2BOOL", current); break;
3894 case ISN_2BOOL: if (iptr->isn_arg.number) 3921 case ISN_2BOOL: if (iptr->isn_arg.number)
3895 smsg("%4d INVERT (!val)", current); 3922 smsg("%4d INVERT (!val)", current);
3896 else 3923 else
3897 smsg("%4d 2BOOL (!!val)", current); 3924 smsg("%4d 2BOOL (!!val)", current);