]> granicus.if.org Git - vim/commitdiff
patch 8.0.1423: error in return not caught by try/catch v8.0.1423
authorBram Moolenaar <Bram@vim.org>
Sat, 23 Dec 2017 16:26:11 +0000 (17:26 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 23 Dec 2017 16:26:11 +0000 (17:26 +0100)
Problem:    Error in return not caught by try/catch.
Solution:   Call update_force_abort(). (Yasuhiro Matsomoto, closes #2483)

src/Makefile
src/testdir/Make_all.mak
src/testdir/test_eval.in
src/testdir/test_eval_stuff.vim [new file with mode: 0644]
src/userfunc.c
src/version.c

index 12357524506fb45174e0353a53c7b2e5fefcae67..beb0de340bf7fccab7b3ce966cb6b5ba795c4f74 100644 (file)
@@ -2147,6 +2147,7 @@ test_arglist \
        test_edit \
        test_erasebackword \
        test_escaped_glob \
+       test_eval_stuff \
        test_ex_undo \
        test_ex_z \
        test_exec_while_if \
index 932f2c43a55a21d26c1b4b5afd9832d32906b50c..050882c5b1dda713c19d6bfdc1be8deb7bb94b04 100644 (file)
@@ -94,6 +94,7 @@ NEW_TESTS = test_arabic.res \
            test_edit.res \
            test_erasebackword.res \
            test_escaped_glob.res \
+           test_eval_stuff.res \
            test_exec_while_if.res \
            test_exists.res \
            test_exists_autocmd.res \
index 84f26bafc1f608b66609b289fb19e33457434cc7..3b61442577bf04b4619d118ab3b76cda36bbffac 100644 (file)
@@ -1,5 +1,7 @@
 Test for various eval features.   vim: set ft=vim :
 
+NOTE: Do not add more here, use new style test test_eval_stuff.vim
+
 Note: system clipboard is saved, changed and restored.
 
 clipboard contents
@@ -134,10 +136,10 @@ if has('clipboard')
 let _clipreg = ['*', getreg('*'), getregtype('*')]
 let _clipopt = &cb
 let &cb='unnamed'
-5y
+7y
 AR *
 tabdo :windo :echo "hi"
-6y
+8y
 AR *
 let &cb=_clipopt
 call call('setreg', _clipreg)
diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim
new file mode 100644 (file)
index 0000000..92e1ec5
--- /dev/null
@@ -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
index 580df0bf834fb6dc46c3ad730a146695211c9ede..931683d7c8f8ccb6ec4b802049c4acf98d5eadec 100644 (file)
@@ -2972,6 +2972,9 @@ 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.
index 65d590506562c495a09e562c7c20a3857b9a9f40..6b3df0dbfd9b299855ce582c74de3065371a11a0 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1423,
 /**/
     1422,
 /**/