Patch 8.2.0287
Problem:    Vim9: return in try block not tested; catch with pattern not
            tested.
Solution:   Add tests.  Make it work.
Files:      src/vim9execute.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.0286/src/vim9execute.c   2020-02-19 22:31:44.886288858 +0100
--- src/vim9execute.c   2020-02-20 20:29:23.509965262 +0100
***************
*** 1065,1070 ****
--- 1065,1071 ----
                    trycmd->tcd_frame = ectx.ec_frame;
                    trycmd->tcd_catch_idx = iptr->isn_arg.try.try_catch;
                    trycmd->tcd_finally_idx = iptr->isn_arg.try.try_finally;
+                   trycmd->tcd_caught = FALSE;
                }
                break;
  
***************
*** 1109,1115 ****
                        --trylevel;
                        trycmd = ((trycmd_T *)trystack->ga_data)
                                                            + trystack->ga_len;
!                       if (trycmd->tcd_caught)
                        {
                            // discard the exception
                            if (caught_stack == current_exception)
--- 1110,1116 ----
                        --trylevel;
                        trycmd = ((trycmd_T *)trystack->ga_data)
                                                            + trystack->ga_len;
!                       if (trycmd->tcd_caught && current_exception != NULL)
                        {
                            // discard the exception
                            if (caught_stack == current_exception)
*** ../vim-8.2.0286/src/testdir/test_vim9_script.vim    2020-02-19 
22:31:44.886288858 +0100
--- src/testdir/test_vim9_script.vim    2020-02-20 20:34:30.640682305 +0100
***************
*** 236,247 ****
--- 236,275 ----
    endtry
  enddef
  
+ def ReturnFinally(): string
+   try
+     return 'intry'
+   finally
+     g:in_finally = 'finally'
+   endtry
+   return 'end'
+ enddef
+ 
  def Test_try_catch_nested()
    CatchInFunc()
    assert_equal('getout', g:thrown_func)
  
    CatchInDef()
    assert_equal('getout', g:thrown_def)
+ 
+   assert_equal('intry', ReturnFinally())
+   assert_equal('finally', g:in_finally)
+ enddef
+ 
+ def Test_try_catch_match()
+   let seq = 'a'
+   try
+     throw 'something'
+   catch /nothing/
+     seq ..= 'x'
+   catch /some/
+     seq ..= 'b'
+   catch /asdf/
+     seq ..= 'x'
+   finally
+     seq ..= 'c'
+   endtry
+   assert_equal('abc', seq)
  enddef
  
  let s:export_script_lines =<< trim END
*** ../vim-8.2.0286/src/version.c       2020-02-20 20:11:50.358377694 +0100
--- src/version.c       2020-02-20 20:31:15.657496681 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     287,
  /**/

-- 
I AM THANKFUL...
...for the taxes that I pay because it means that I am employed.

 /// 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/202002201941.01KJfXPx011253%40masaka.moolenaar.net.

Raspunde prin e-mail lui