Compare commits

...

3 Commits

Author SHA1 Message Date
Bram Moolenaar
d3d8feeb89 patch 8.2.3077: Vim9: an error in a catch block is not reported
Problem:    Vim9: an error in a catch block is not reported.
Solution:   Put the "in catch" flag in the try stack. (closes #8478)
2021-06-30 19:54:43 +02:00
Bram Moolenaar
3f987b5917 patch 8.2.3076: Vim9: using try in catch block causes a hang
Problem:    Vim9: using try in catch block causes a hang.
Solution:   Save and restore the ec_in_catch flag. (closes #8478)
2021-06-30 12:02:24 +02:00
=?UTF-8?q?J=C3=BCrgen=20Weigert?=
80b2ba3e96 patch 8.2.3075: xxd always reports an old version string
Problem:    Xxd always reports an old version string. (Åsmund Ervik)
Solution:   Update the version string with the last known change date.
            (Jürgen Weigert, closes #8475)
2021-06-29 20:36:25 +02:00
5 changed files with 91 additions and 14 deletions

View File

@@ -605,6 +605,43 @@ def Test_try_catch_throw()
unlet g:caught
enddef
def Test_try_in_catch()
var lines =<< trim END
vim9script
var seq = []
def DoIt()
try
seq->add('throw 1')
eval [][0]
seq->add('notreached')
catch
seq->add('catch')
try
seq->add('throw 2')
eval [][0]
seq->add('notreached')
catch /nothing/
seq->add('notreached')
endtry
seq->add('done')
endtry
enddef
DoIt()
assert_equal(['throw 1', 'catch', 'throw 2', 'done'], seq)
END
enddef
def Test_error_in_catch()
var lines =<< trim END
try
eval [][0]
catch /E684:/
eval [][0]
endtry
END
CheckDefExecFailure(lines, 'E684:', 4)
enddef
" :while at the very start of a function that :continue jumps to
def TryContinueFunc()
while g:Count < 2
@@ -742,6 +779,30 @@ def Test_try_catch_nested()
assert_equal('intry', ReturnFinally())
assert_equal('finally', g:in_finally)
var l = []
try
l->add('1')
throw 'bad'
l->add('x')
catch /bad/
l->add('2')
try
l->add('3')
throw 'one'
l->add('x')
catch /one/
l->add('4')
try
l->add('5')
throw 'more'
l->add('x')
catch /more/
l->add('6')
endtry
endtry
endtry
assert_equal(['1', '2', '3', '4', '5', '6'], l)
enddef
def TryOne(): number

View File

@@ -226,7 +226,7 @@ endfunc
func Test_xxd_version()
new
exe 'r! ' . s:xxd_cmd . ' -v'
call assert_match("xxd V1.10 .* by Juergen Weigert", join(getline(1, 3)))
call assert_match('xxd 20\d\d-\d\d-\d\d by Juergen Weigert et al\.', join(getline(1, 3)))
bwipe!
endfunc

View File

@@ -755,6 +755,12 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3077,
/**/
3076,
/**/
3075,
/**/
3074,
/**/

View File

@@ -26,6 +26,8 @@
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_in_catch; // in catch or finally block
int tcd_did_throw; // set did_throw in :endtry
int tcd_catch_idx; // instruction of the first :catch or :finally
int tcd_finally_idx; // instruction of the :finally block or zero
int tcd_endtry_idx; // instruction of the :endtry
@@ -82,7 +84,6 @@ struct ectx_S {
funclocal_T ec_funclocal;
garray_T ec_trystack; // stack of trycmd_T values
int ec_in_catch; // when TRUE in catch or finally block
int ec_dfunc_idx; // current function index
isn_T *ec_instr; // array with instructions
@@ -1565,20 +1566,31 @@ exec_instructions(ectx_T *ectx)
*msg_list = NULL;
}
if (did_throw && !ectx->ec_in_catch)
if (did_throw)
{
garray_T *trystack = &ectx->ec_trystack;
trycmd_T *trycmd = NULL;
int index = trystack->ga_len;
// An exception jumps to the first catch, finally, or returns from
// the current function.
if (trystack->ga_len > 0)
trycmd = ((trycmd_T *)trystack->ga_data) + trystack->ga_len - 1;
while (index > 0)
{
trycmd = ((trycmd_T *)trystack->ga_data) + index - 1;
if (!trycmd->tcd_in_catch)
break;
// In the catch and finally block of this try we have to go up
// one level.
--index;
trycmd = NULL;
}
if (trycmd != NULL && trycmd->tcd_frame_idx == ectx->ec_frame_idx)
{
// jump to ":catch" or ":finally"
ectx->ec_in_catch = TRUE;
trycmd->tcd_in_catch = TRUE;
ectx->ec_iidx = trycmd->tcd_catch_idx;
did_throw = FALSE; // don't come back here until :endtry
trycmd->tcd_did_throw = TRUE;
}
else
{
@@ -3202,6 +3214,7 @@ exec_instructions(ectx_T *ectx)
trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - 1;
trycmd->tcd_caught = TRUE;
trycmd->tcd_did_throw = FALSE;
}
did_emsg = got_int = did_throw = FALSE;
force_abort = need_rethrow = FALSE;
@@ -3263,9 +3276,10 @@ exec_instructions(ectx_T *ectx)
--trystack->ga_len;
--trylevel;
ectx->ec_in_catch = FALSE;
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len;
if (trycmd->tcd_did_throw)
did_throw = TRUE;
if (trycmd->tcd_caught && current_exception != NULL)
{
// discard the exception

View File

@@ -55,16 +55,12 @@
* 11.01.2019 Add full 64/32 bit range to -o and output by Christer Jensen.
* 04.02.2020 Add -d for decimal offsets by Aapo Rantalainen
*
* (c) 1990-1998 by Juergen Weigert (jnweiger@informatik.uni-erlangen.de)
* (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com)
*
* I hereby grant permission to distribute and use xxd
* under X11-MIT or GPL-2.0 (at the user's choice).
*
* Small changes made afterwards by Bram Moolenaar et al.
*
* Distribute freely and credit me,
* make money and share with me,
* lose money and don't ask me.
* Contributions by Bram Moolenaar et al.
*/
/* Visual Studio 2005 has 'deprecated' many of the standard CRT functions */
@@ -135,7 +131,7 @@ extern void perror __P((char *));
extern long int strtol();
extern long int ftell();
char version[] = "xxd V1.10 27oct98 by Juergen Weigert";
char version[] = "xxd 2020-02-04 by Juergen Weigert et al.";
#ifdef WIN32
char osver[] = " (Win32)";
#else