Mercurial > vim
diff src/vim9compile.c @ 25224:10a5eb15a3bf v8.2.3148
patch 8.2.3148: Vim9: function arg type check does not handle base offset
Commit: https://github.com/vim/vim/commit/5231224e11bf468f5366a7400414368908c40795
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 11 18:23:19 2021 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 11 Jul 2021 18:30:03 +0200 |
parents | fbb530e081ca |
children | 658dfd6be868 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1781,6 +1781,7 @@ generate_BCALL(cctx_T *cctx, int func_id 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 @@ generate_BCALL(cctx_T *cctx, int func_id { // 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;