Patch 8.2.2503
Problem: Vim9: a caught error may leave something on the stack.
Solution: Drop items from the stack if needed. (closes #7826)
Files: src/vim9execute.c, src/testdir/test_vim9_script.vim
*** ../vim-8.2.2502/src/vim9execute.c 2021-02-11 21:19:30.522147936 +0100
--- src/vim9execute.c 2021-02-12 21:31:20.581143095 +0100
***************
*** 24,30 ****
// Structure put on ec_trystack when ISN_TRY is encountered.
typedef struct {
! int tcd_frame_idx; // ec_frame_idx when ISN_TRY was
encountered
int tcd_catch_idx; // instruction of the first catch
int tcd_finally_idx; // instruction of the finally block
int tcd_caught; // catch block entered
--- 24,31 ----
// Structure put on ec_trystack when ISN_TRY is encountered.
typedef struct {
! int tcd_frame_idx; // ec_frame_idx at ISN_TRY
! int tcd_stack_len; // size of ectx.ec_stack at ISN_TRY
int tcd_catch_idx; // instruction of the first catch
int tcd_finally_idx; // instruction of the finally block
int tcd_caught; // catch block entered
***************
*** 2561,2566 ****
--- 2562,2568 ----
++ectx.ec_trystack.ga_len;
++trylevel;
trycmd->tcd_frame_idx = ectx.ec_frame_idx;
+ trycmd->tcd_stack_len = ectx.ec_stack.ga_len;
trycmd->tcd_catch_idx = iptr->isn_arg.try.try_catch;
trycmd->tcd_finally_idx = iptr->isn_arg.try.try_finally;
trycmd->tcd_caught = FALSE;
***************
*** 2632,2637 ****
--- 2634,2645 ----
if (trycmd->tcd_return)
goto func_return;
+
+ while (ectx.ec_stack.ga_len > trycmd->tcd_stack_len)
+ {
+ --ectx.ec_stack.ga_len;
+ clear_tv(STACK_TV_BOT(0));
+ }
}
}
break;
*** ../vim-8.2.2502/src/testdir/test_vim9_script.vim 2021-02-07
17:17:54.739378027 +0100
--- src/testdir/test_vim9_script.vim 2021-02-12 21:29:17.201466785 +0100
***************
*** 556,561 ****
--- 556,571 ----
n = 411
endtry
assert_equal(411, n)
+
+ var counter = 0
+ for i in range(4)
+ try
+ eval [][0]
+ catch
+ endtry
+ counter += 1
+ endfor
+ assert_equal(4, counter)
enddef
def Test_cnext_works_in_catch()
*** ../vim-8.2.2502/src/version.c 2021-02-12 19:48:47.888057588 +0100
--- src/version.c 2021-02-12 21:26:52.093960027 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2503,
/**/
--
Q: How does a UNIX Guru pick up a girl?
A: look; grep; which; eval; nice; uname; talk; date;
/// 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/202102122033.11CKXtob960668%40masaka.moolenaar.net.