Mercurial > vim
diff src/vim9execute.c @ 21757:6c03897bcd60 v8.2.1428
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Commit: https://github.com/vim/vim/commit/ed677f5587af366f185f8922b7dde4a98c884328
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 12 16:38:10 2020 +0200
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Problem: Vim9: :def function does not abort on nested function error.
Solution: Check whether an error message was given. (closes https://github.com/vim/vim/issues/6691)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Aug 2020 16:45:04 +0200 |
parents | 9ef7ae8ab51c |
children | fcf978444298 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -505,6 +505,7 @@ call_ufunc(ufunc_T *ufunc, int argcount, funcexe_T funcexe; int error; int idx; + int called_emsg_before = called_emsg; if (ufunc->uf_def_status == UF_TO_BE_COMPILED && compile_def_function(ufunc, FALSE, NULL) == FAIL) @@ -542,6 +543,9 @@ call_ufunc(ufunc_T *ufunc, int argcount, user_func_error(error, ufunc->uf_name); return FAIL; } + if (called_emsg > called_emsg_before) + // Error other than from calling the function itself. + return FAIL; return OK; } @@ -670,10 +674,11 @@ store_var(char_u *name, typval_T *tv) static int call_eval_func(char_u *name, int argcount, ectx_T *ectx, isn_T *iptr) { - int called_emsg_before = called_emsg; - - if (call_by_name(name, argcount, ectx, iptr) == FAIL - && called_emsg == called_emsg_before) + int called_emsg_before = called_emsg; + int res; + + res = call_by_name(name, argcount, ectx, iptr); + if (res == FAIL && called_emsg == called_emsg_before) { dictitem_T *v; @@ -690,7 +695,7 @@ call_eval_func(char_u *name, int argcoun } return call_partial(&v->di_tv, argcount, ectx); } - return OK; + return res; } /*