Mercurial > vim
diff src/vim9execute.c @ 33936:bdd408288d95 v9.0.2164
patch 9.0.2164: Vim9: can use type a func arg/return value
Commit: https://github.com/vim/vim/commit/b077b58809f6bd1078f409829cc1964b8475f9fc
Author: Ernie Rael <errael@raelity.com>
Date: Thu Dec 14 20:11:44 2023 +0100
patch 9.0.2164: Vim9: can use type a func arg/return value
Problem: Vim9: can use type a func arg/return value
Solution: Check if using type as function argument or return value
closes: #13675
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 14 Dec 2023 20:15:10 +0100 |
parents | a259471e74fe |
children | 45a50fd59a73 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -398,6 +398,9 @@ check_ufunc_arg_types(ufunc_T *ufunc, in if (argv[i].v_type == VAR_SPECIAL && argv[i].vval.v_number == VVAL_NONE) continue; + // only pass values to user functions, never types + if (check_typval_is_value(&argv[i]) == FAIL) + return FAIL; if (i < ufunc->uf_args.ga_len && ufunc->uf_arg_types != NULL) type = ufunc->uf_arg_types[i]; @@ -4462,6 +4465,12 @@ exec_instructions(ectx_T *ectx) garray_T *trystack = &ectx->ec_trystack; trycmd_T *trycmd = NULL; + /////////////////////////////////////////////////// + // TODO: If FAIL, line number in output not correct + /////////////////////////////////////////////////// + if (check_typval_is_value(STACK_TV_BOT(-1)) == FAIL) + goto theend; + if (trystack->ga_len > 0) trycmd = ((trycmd_T *)trystack->ga_data) + trystack->ga_len - 1;