forked from aniani/vim
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Problem: Vim9: a caught error may leave something on the stack. Solution: Drop items from the stack if needed. (closes #7826)
This commit is contained in:
parent
ca753ec862
commit
d9d7789b6f
@ -556,6 +556,16 @@ def Test_try_catch_throw()
|
|||||||
n = 411
|
n = 411
|
||||||
endtry
|
endtry
|
||||||
assert_equal(411, n)
|
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
|
enddef
|
||||||
|
|
||||||
def Test_cnext_works_in_catch()
|
def Test_cnext_works_in_catch()
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2503,
|
||||||
/**/
|
/**/
|
||||||
2502,
|
2502,
|
||||||
/**/
|
/**/
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
// Structure put on ec_trystack when ISN_TRY is encountered.
|
// Structure put on ec_trystack when ISN_TRY is encountered.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int tcd_frame_idx; // ec_frame_idx when ISN_TRY was encountered
|
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_catch_idx; // instruction of the first catch
|
||||||
int tcd_finally_idx; // instruction of the finally block
|
int tcd_finally_idx; // instruction of the finally block
|
||||||
int tcd_caught; // catch block entered
|
int tcd_caught; // catch block entered
|
||||||
@ -2561,6 +2562,7 @@ call_def_function(
|
|||||||
++ectx.ec_trystack.ga_len;
|
++ectx.ec_trystack.ga_len;
|
||||||
++trylevel;
|
++trylevel;
|
||||||
trycmd->tcd_frame_idx = ectx.ec_frame_idx;
|
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_catch_idx = iptr->isn_arg.try.try_catch;
|
||||||
trycmd->tcd_finally_idx = iptr->isn_arg.try.try_finally;
|
trycmd->tcd_finally_idx = iptr->isn_arg.try.try_finally;
|
||||||
trycmd->tcd_caught = FALSE;
|
trycmd->tcd_caught = FALSE;
|
||||||
@ -2632,6 +2634,12 @@ call_def_function(
|
|||||||
|
|
||||||
if (trycmd->tcd_return)
|
if (trycmd->tcd_return)
|
||||||
goto func_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;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user