Mercurial > vim
diff src/vim9compile.c @ 19564:06f29b6ea04a v8.2.0339
patch 8.2.0339: Vim9: function return type may depend on arguments
Commit: https://github.com/vim/vim/commit/fbdd08ed9b1798885915c7f27c94786906d258e4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 1 14:04:46 2020 +0100
patch 8.2.0339: Vim9: function return type may depend on arguments
Problem: Vim9: function return type may depend on arguments.
Solution: Instead of a fixed return type use a function to figure out the
return type.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Mar 2020 14:15:04 +0100 |
parents | 6b7719b8f9b9 |
children | ec1eeb1b69e2 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -992,6 +992,8 @@ generate_BCALL(cctx_T *cctx, int func_id { isn_T *isn; garray_T *stack = &cctx->ctx_type_stack; + type_T *argtypes[MAX_FUNC_ARGS]; + int i; if (check_internal_func(func_idx, argcount) == FAIL) return FAIL; @@ -1001,11 +1003,14 @@ generate_BCALL(cctx_T *cctx, int func_id isn->isn_arg.bfunc.cbf_idx = func_idx; isn->isn_arg.bfunc.cbf_argcount = argcount; + for (i = 0; i < argcount; ++i) + argtypes[i] = ((type_T **)stack->ga_data)[stack->ga_len - argcount + i]; + stack->ga_len -= argcount; // drop the arguments if (ga_grow(stack, 1) == FAIL) return FAIL; ((type_T **)stack->ga_data)[stack->ga_len] = - internal_func_ret_type(func_idx, argcount); + internal_func_ret_type(func_idx, argcount, argtypes); ++stack->ga_len; // add return value return OK; @@ -1374,7 +1379,7 @@ parse_type(char_u **arg, garray_T *type_ } break; case 'p': - if (len == 4 && STRNCMP(*arg, "partial", len) == 0) + if (len == 7 && STRNCMP(*arg, "partial", len) == 0) { *arg += len; // TODO: arguments and return type