mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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)
This commit is contained in:
@@ -2994,6 +2994,24 @@ call_def_function(
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_SETTYPE:
|
||||
{
|
||||
checktype_T *ct = &iptr->isn_arg.type;
|
||||
|
||||
tv = STACK_TV_BOT(-1);
|
||||
if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
|
||||
{
|
||||
free_type(tv->vval.v_dict->dv_type);
|
||||
tv->vval.v_dict->dv_type = alloc_type(ct->ct_type);
|
||||
}
|
||||
else if (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)
|
||||
{
|
||||
free_type(tv->vval.v_list->lv_type);
|
||||
tv->vval.v_list->lv_type = alloc_type(ct->ct_type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_2BOOL:
|
||||
case ISN_COND2BOOL:
|
||||
{
|
||||
@@ -3890,6 +3908,15 @@ ex_disassemble(exarg_T *eap)
|
||||
iptr->isn_arg.checklen.cl_more_OK ? ">= " : "",
|
||||
iptr->isn_arg.checklen.cl_min_len);
|
||||
break;
|
||||
case ISN_SETTYPE:
|
||||
{
|
||||
char *tofree;
|
||||
|
||||
smsg("%4d SETTYPE %s", current,
|
||||
type_name(iptr->isn_arg.type.ct_type, &tofree));
|
||||
vim_free(tofree);
|
||||
break;
|
||||
}
|
||||
case ISN_COND2BOOL: smsg("%4d COND2BOOL", current); break;
|
||||
case ISN_2BOOL: if (iptr->isn_arg.number)
|
||||
smsg("%4d INVERT (!val)", current);
|
||||
|
Reference in New Issue
Block a user