From c2e7f39528a5270fbc44469296158e98ba5838f9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 3 Sep 2018 22:31:04 -0400 Subject: vim-patch:8.0.1423: error in return not caught by try/catch Problem: Error in return not caught by try/catch. Solution: Call update_force_abort(). (Yasuhiro Matsomoto, closes vim/vim#2483) https://github.com/vim/vim/commit/fabaf753e26df5a89a854673d14c15a1fa6b321a --- src/nvim/eval.c | 3 +++ src/nvim/testdir/test_eval_stuff.vim | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/nvim/testdir/test_eval_stuff.vim (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9c678168bb..512a8dc511 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21800,6 +21800,9 @@ void ex_return(exarg_T *eap) } /* It's safer to return also on error. */ else if (!eap->skip) { + // In return statement, cause_abort should be force_abort. + update_force_abort(); + /* * Return unless the expression evaluation has been cancelled due to an * aborting error, an interrupt, or an exception. diff --git a/src/nvim/testdir/test_eval_stuff.vim b/src/nvim/testdir/test_eval_stuff.vim new file mode 100644 index 0000000000..92e1ec5335 --- /dev/null +++ b/src/nvim/testdir/test_eval_stuff.vim @@ -0,0 +1,13 @@ +" Tests for various eval things. + +function s:foo() abort + try + return [] == 0 + catch + return 1 + endtry +endfunction + +func Test_catch_return_with_error() + call assert_equal(1, s:foo()) +endfunc -- cgit