diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-12-29 20:56:24 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-29 20:56:24 +0000 |
commit | c6951a76a58663ef8a773d340f2260da7455643c (patch) | |
tree | 85498d64d07c8c65919d0938494a754a213e21c4 /src/vim9expr.c | |
parent | 73ade49c4b692e77d2c0b2ef0afbedbf55c5f946 (diff) | |
download | vim-git-c6951a76a58663ef8a773d340f2260da7455643c.tar.gz |
patch 9.0.1108: type error when using "any" type and adding to floatv9.0.1108
Problem: Type error when using "any" type and adding a number to a float.
Solution: Accept both a number and a float. (closes #11753)
Diffstat (limited to 'src/vim9expr.c')
-rw-r--r-- | src/vim9expr.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/vim9expr.c b/src/vim9expr.c index b4e201eb5..ba2c826cf 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -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; |