summaryrefslogtreecommitdiffstats
path: root/src/vim9type.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-12-29 20:56:24 +0000
committerBram Moolenaar <Bram@vim.org>2022-12-29 20:56:24 +0000
commitc6951a76a58663ef8a773d340f2260da7455643c (patch)
tree85498d64d07c8c65919d0938494a754a213e21c4 /src/vim9type.c
parent73ade49c4b692e77d2c0b2ef0afbedbf55c5f946 (diff)
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/vim9type.c')
-rw-r--r--src/vim9type.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/vim9type.c b/src/vim9type.c
index 393c69d7e7..436a42de51 100644
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -813,6 +813,11 @@ check_type_maybe(
&& (actual->tt_flags & TTFLAG_BOOL_OK))
// Using number 0 or 1 for bool is OK.
return OK;
+ if (expected->tt_type == VAR_FLOAT
+ && (expected->tt_flags & TTFLAG_NUMBER_OK)
+ && actual->tt_type == VAR_NUMBER)
+ // Using number where float is expected is OK here.
+ return OK;
if (give_msg)
type_mismatch_where(expected, actual, where);
return FAIL;
@@ -848,7 +853,8 @@ check_type_maybe(
{
int i;
- for (i = 0; i < expected->tt_argcount && i < actual->tt_argcount; ++i)
+ for (i = 0; i < expected->tt_argcount
+ && i < actual->tt_argcount; ++i)
// Allow for using "any" argument type, lambda's have them.
if (actual->tt_args[i] != &t_any && check_type(
expected->tt_args[i], actual->tt_args[i], FALSE,