patch 8.2.3148: Vim9: function arg type check does not handle base offset
Problem: Vim9: function arg type check does not handle base offset.
Solution: Take the base offset into account when checking builtin function
argument types.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index b04e750..15c8ef6 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1781,6 +1781,7 @@
garray_T *stack = &cctx->ctx_type_stack;
int argoff;
type_T **argtypes = NULL;
+ type_T *shuffled_argtypes[MAX_FUNC_ARGS];
type_T *maptype = NULL;
RETURN_OK_IF_SKIP(cctx);
@@ -1800,6 +1801,16 @@
{
// Check the types of the arguments.
argtypes = ((type_T **)stack->ga_data) + stack->ga_len - argcount;
+ if (method_call && argoff > 1)
+ {
+ int i;
+
+ for (i = 0; i < argcount; ++i)
+ shuffled_argtypes[i] = (i < argoff - 1)
+ ? argtypes[i + 1]
+ : (i == argoff - 1) ? argtypes[0] : argtypes[i];
+ argtypes = shuffled_argtypes;
+ }
if (internal_func_check_arg_types(argtypes, func_idx, argcount,
cctx) == FAIL)
return FAIL;