Patch 8.2.0280
Problem:    Vim9: throw in :def function not caught higher up.
Solution:   Set "need_rethrow".
Files:      src/vim9execute.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.0279/src/vim9execute.c   2020-02-16 15:03:44.193305731 +0100
--- src/vim9execute.c   2020-02-19 16:26:01.145998771 +0100
***************
*** 482,487 ****
--- 482,488 ----
                    tv->v_type = VAR_NUMBER;
                    tv->vval.v_number = 0;
                    ++ectx.ec_stack.ga_len;
+                   need_rethrow = TRUE;
                    goto done;
                }
  
*** ../vim-8.2.0279/src/testdir/test_vim9_script.vim    2020-02-19 
15:46:45.269950987 +0100
--- src/testdir/test_vim9_script.vim    2020-02-19 16:35:28.839605442 +0100
***************
*** 206,211 ****
--- 206,239 ----
    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'
*** ../vim-8.2.0279/src/version.c       2020-02-19 15:46:45.269950987 +0100
--- src/version.c       2020-02-19 16:33:00.712207458 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     280,
  /**/

-- 
>From "know your smileys":
 %-)    After staring at screen for 15 hours

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202002191606.01JG6h1l008805%40masaka.moolenaar.net.

Raspunde prin e-mail lui