Skip to content

Commit 6e9f7bc

Browse files
author
Fraser J. Gordon
committed
Ensure errors are cleared before re-trying statements
1 parent 6cefeef commit 6e9f7bc

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

engine/src/cmdse.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ void MCDispatchCmd::exec_ctxt(MCExecContext &ctxt)
10861086
t_target_ptr = nil;
10871087

10881088
// Evaluate the parameter list
1089-
bool t_success;
1089+
bool t_success, t_can_debug;
10901090
MCParameter *tptr = params;
10911091
while (tptr != NULL)
10921092
{
@@ -1099,10 +1099,17 @@ void MCDispatchCmd::exec_ctxt(MCExecContext &ctxt)
10991099
{
11001100
MCAutoValueRef t_value;
11011101
tptr -> clear_argument();
1102-
while (!(t_success = tptr->eval(ctxt, &t_value))
1103-
&& (MCtrace || MCnbreakpoints)
1104-
&& !MCtrylock && !MClockerrors)
1105-
MCB_error(ctxt, line, pos, EE_STATEMENT_BADPARAM);
1102+
1103+
do
1104+
{
1105+
if (!(t_success = tptr->eval(ctxt, &t_value)))
1106+
t_success = true;
1107+
else
1108+
t_can_debug = MCB_error(ctxt, line, pos, EE_STATEMENT_BADPARAM);
1109+
ctxt.IgnoreLastError();
1110+
}
1111+
while (!t_success && t_can_debug && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors);
1112+
11061113
if (!t_success)
11071114
{
11081115
ctxt . LegacyThrow(EE_STATEMENT_BADPARAM);

engine/src/exec-keywords.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ static Exec_stat MCKeywordsExecuteStatements(MCExecContext& ctxt, MCStatement *p
8484
if ((MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors)
8585
do
8686
{
87-
ctxt . IgnoreLastError();
8887
MCB_error(ctxt, tspr->getline(), tspr->getpos(),
8988
EE_REPEAT_BADSTATEMENT);
89+
ctxt . IgnoreLastError();
9090
tspr->exec_ctxt(ctxt);
9191
}
9292
while (MCtrace && (stat = ctxt . GetExecStat()) != ES_NORMAL);
@@ -700,6 +700,7 @@ void MCKeywordsExecTry(MCExecContext& ctxt, MCStatement *trystatements, MCStatem
700700
do
701701
{
702702
MCB_error(ctxt, tspr->getline(), tspr->getpos(), EE_TRY_BADSTATEMENT);
703+
ctxt.IgnoreLastError();
703704
tspr->exec_ctxt(ctxt);
704705
}
705706
while(MCtrace && (stat = ctxt . GetExecStat()) != ES_NORMAL);

engine/src/handler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ Exec_stat MCHandler::exec(MCExecContext& ctxt, MCParameter *plist)
441441
do
442442
{
443443
MCB_error(ctxt, tspr->getline(), tspr->getpos(), EE_HANDLER_BADSTATEMENT);
444+
ctxt . IgnoreLastError();
444445
tspr->exec_ctxt(ctxt);
445446
}
446447
while (MCtrace && (stat = ctxt . GetExecStat()) != ES_NORMAL);

0 commit comments

Comments
 (0)