0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 9.0.1108: type error when using "any" type and adding to float

Problem:    Type error when using "any" type and adding a number to a float.
Solution:   Accept both a number and a float. (closes #11753)
This commit is contained in:
Bram Moolenaar
2022-12-29 20:56:24 +00:00
parent 73ade49c4b
commit c6951a76a5
12 changed files with 117 additions and 54 deletions

View File

@@ -99,13 +99,14 @@ compile_member(int is_slice, int *keeping_dict, cctx_T *cctx)
vartype = VAR_DICT;
if (vartype == VAR_STRING || vartype == VAR_LIST || vartype == VAR_BLOB)
{
if (need_type(idxtype, &t_number, -1, 0, cctx, FALSE, FALSE) == FAIL)
if (need_type(idxtype, &t_number, FALSE,
-1, 0, cctx, FALSE, FALSE) == FAIL)
return FAIL;
if (is_slice)
{
idxtype = get_type_on_stack(cctx, 1);
if (need_type(idxtype, &t_number, -2, 0, cctx,
FALSE, FALSE) == FAIL)
if (need_type(idxtype, &t_number, FALSE,
-2, 0, cctx, FALSE, FALSE) == FAIL)
return FAIL;
}
}
@@ -135,8 +136,8 @@ compile_member(int is_slice, int *keeping_dict, cctx_T *cctx)
}
else
{
if (need_type(typep->type_curr, &t_dict_any, -2, 0, cctx,
FALSE, FALSE) == FAIL)
if (need_type(typep->type_curr, &t_dict_any, FALSE,
-2, 0, cctx, FALSE, FALSE) == FAIL)
return FAIL;
typep->type_curr = &t_any;
typep->type_decl = &t_any;
@@ -1725,7 +1726,7 @@ bool_on_stack(cctx_T *cctx)
// This requires a runtime type check.
return generate_COND2BOOL(cctx);
return need_type(type, &t_bool, -1, 0, cctx, FALSE, FALSE);
return need_type(type, &t_bool, FALSE, -1, 0, cctx, FALSE, FALSE);
}
/*
@@ -1759,7 +1760,7 @@ compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end)
{
type_T *type = get_type_on_stack(cctx, 0);
if (type->tt_type != VAR_FLOAT && need_type(type, &t_number,
-1, 0, cctx, FALSE, FALSE) == FAIL)
FALSE, -1, 0, cctx, FALSE, FALSE) == FAIL)
return FAIL;
// only '-' has an effect, for '+' we only check the type
@@ -2517,8 +2518,8 @@ compile_expr8(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
actual = get_type_on_stack(cctx, 0);
if (check_type_maybe(want_type, actual, FALSE, where) != OK)
{
if (need_type(actual, want_type, -1, 0, cctx, FALSE, FALSE)
== FAIL)
if (need_type(actual, want_type, FALSE,
-1, 0, cctx, FALSE, FALSE) == FAIL)
return FAIL;
}
}
@@ -2759,7 +2760,7 @@ compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
{
type_T *t = get_type_on_stack(cctx, 0);
if (need_type(t, &t_number, 0, 0, cctx, FALSE, FALSE) == FAIL)
if (need_type(t, &t_number, FALSE, 0, 0, cctx, FALSE, FALSE) == FAIL)
{
emsg(_(e_bitshift_ops_must_be_number));
return FAIL;
@@ -2814,8 +2815,8 @@ compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
}
else
{
if (need_type(get_type_on_stack(cctx, 0), &t_number, 0, 0, cctx,
FALSE, FALSE) == FAIL)
if (need_type(get_type_on_stack(cctx, 0), &t_number, FALSE,
0, 0, cctx, FALSE, FALSE) == FAIL)
{
emsg(_(e_bitshift_ops_must_be_number));
return FAIL;