Patch 8.2.0287

9 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 20, 2020, 2:41:43 PM2/20/20
to vim...@googlegroups.com

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 -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages