]> granicus.if.org Git - vim/commitdiff
patch 8.2.0280: Vim9: throw in :def function not caught higher up v8.2.0280
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Feb 2020 16:06:11 +0000 (17:06 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Feb 2020 16:06:11 +0000 (17:06 +0100)
Problem:    Vim9: throw in :def function not caught higher up.
Solution:   Set "need_rethrow".

src/testdir/test_vim9_script.vim
src/version.c
src/vim9execute.c

index 899a32aa6e03b619c666faff2608a89deb3a1528..ae33935072c056fa623c4d4af8ae0d62e76d5cf0 100644 (file)
@@ -206,6 +206,34 @@ def Test_try_catch()
   assert_equal(['1', 'wrong', '3'], l)
 enddef
 
+def ThrowFromDef()
+  throw 'getout'
+enddef
+
+func CatchInFunc()
+  try
+    call ThrowFromDef()
+  catch
+    let g:thrown_func = v:exception
+  endtry
+endfunc
+
+def CatchInDef()
+  try
+    ThrowFromDef()
+  catch
+    g:thrown_def = v:exception
+  endtry
+enddef
+
+def Test_try_catch_nested()
+  CatchInFunc()
+  assert_equal('getout', g:thrown_func)
+
+  CatchInDef()
+  assert_equal('getout', g:thrown_def)
+enddef
+
 let s:export_script_lines =<< trim END
   vim9script
   let name: string = 'bob'
index d748416caee68bb7b5eff62c5c17608f44807f78..2ff3460757c5d009fb40fbb14b9f1dc39db9f444 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    280,
 /**/
     279,
 /**/
index 45557481102a107b6cce91131444e9051bfafb25..4349489e54dd77ea40dd6b9aaeb53a720491bd53 100644 (file)
@@ -482,6 +482,7 @@ call_def_function(
                    tv->v_type = VAR_NUMBER;
                    tv->vval.v_number = 0;
                    ++ectx.ec_stack.ga_len;
+                   need_rethrow = TRUE;
                    goto done;
                }