0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected

Problem:    Vim9: list<any> is not accepted where list<number> is expected.
Solution:   Add functions to allocate and free a type_T, use it in
            ISN_CHECKTYPE. (closes #6959)
This commit is contained in:
Bram Moolenaar
2020-09-16 15:22:00 +02:00
parent 8b51b7f0f1
commit 5e65423077
13 changed files with 253 additions and 149 deletions

View File

@@ -2535,30 +2535,19 @@ call_def_function(
checktype_T *ct = &iptr->isn_arg.type;
tv = STACK_TV_BOT(ct->ct_off);
// TODO: better type comparison
if (tv->v_type != ct->ct_type
&& !((tv->v_type == VAR_PARTIAL
&& ct->ct_type == VAR_FUNC)
|| (tv->v_type == VAR_FUNC
&& ct->ct_type == VAR_PARTIAL)))
SOURCING_LNUM = iptr->isn_lnum;
if (check_typval_type(ct->ct_type, tv, 0) == FAIL)
goto on_error;
// number 0 is FALSE, number 1 is TRUE
if (tv->v_type == VAR_NUMBER
&& ct->ct_type->tt_type == VAR_BOOL
&& (tv->vval.v_number == 0
|| tv->vval.v_number == 1))
{
if (tv->v_type == VAR_NUMBER && ct->ct_type == VAR_BOOL
&& (tv->vval.v_number == 0
|| tv->vval.v_number == 1))
{
// number 0 is FALSE, number 1 is TRUE
tv->v_type = VAR_BOOL;
tv->vval.v_number = tv->vval.v_number
tv->v_type = VAR_BOOL;
tv->vval.v_number = tv->vval.v_number
? VVAL_TRUE : VVAL_FALSE;
}
else
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_expected_str_but_got_str),
vartype_name(ct->ct_type),
vartype_name(tv->v_type));
goto on_error;
}
}
}
break;
@@ -3286,10 +3275,16 @@ ex_disassemble(exarg_T *eap)
case ISN_NEGATENR: smsg("%4d NEGATENR", current); break;
case ISN_CHECKNR: smsg("%4d CHECKNR", current); break;
case ISN_CHECKTYPE: smsg("%4d CHECKTYPE %s stack[%d]", current,
vartype_name(iptr->isn_arg.type.ct_type),
iptr->isn_arg.type.ct_off);
break;
case ISN_CHECKTYPE:
{
char *tofree;
smsg("%4d CHECKTYPE %s stack[%d]", current,
type_name(iptr->isn_arg.type.ct_type, &tofree),
iptr->isn_arg.type.ct_off);
vim_free(tofree);
break;
}
case ISN_CHECKLEN: smsg("%4d CHECKLEN %s%d", current,
iptr->isn_arg.checklen.cl_more_OK ? ">= " : "",
iptr->isn_arg.checklen.cl_min_len);