Skip to content

Commit 4236d80

Browse files
committed
core: fix error level in try/catch
When the multi-level break/continue support was added in 1b151f8 it reused returnLevel, but this interferred with the return level returned by try/catch. Use a separate variable for the break/continue level. Signed-off-by: Steve Bennett <[email protected]>
1 parent 067a64f commit 4236d80

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

jim.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12265,15 +12265,15 @@ static int Jim_UnsetCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *ar
1226512265

1226612266
/**
1226712267
* All commands that support break, continue from a loop (while, loop, foreach, for)
12268-
* use this to check for returnLevel.
12268+
* use this to check for break_level.
1226912269
*
12270-
* If returnLevel is > 0, decrements the returnLevel and returns 1.
12270+
* If break_level is > 0, decrements the break_level and returns 1.
1227112271
* Otherwise returns 0
1227212272
*/
1227312273
static int JimCheckLoopRetcode(Jim_Interp *interp, int retval)
1227412274
{
1227512275
if (retval == JIM_BREAK || retval == JIM_CONTINUE) {
12276-
if (--interp->returnLevel > 0) {
12276+
if (--interp->break_level > 0) {
1227712277
return 1;
1227812278
}
1227912279
}
@@ -13837,7 +13837,7 @@ static int JimBreakContinueHelper(Jim_Interp *interp, int argc, Jim_Obj *const *
1383713837
if (ret != JIM_OK) {
1383813838
return ret;
1383913839
}
13840-
interp->returnLevel = level;
13840+
interp->break_level = level;
1384113841
}
1384213842
return retcode;
1384313843
}

jim.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ typedef struct Jim_Interp {
542542
Jim_Obj *result; /* object returned by the last command called. */
543543
int unused_errorLine; /* Error line where an error occurred. */
544544
Jim_Obj *currentFilenameObj; /* filename of current Jim_EvalFile() */
545-
int unused_addStackTrace;
545+
int break_level; /* break/continue level */
546546
int maxCallFrameDepth; /* Used for infinite loop detection. */
547547
int maxEvalDepth; /* Used for infinite loop detection. */
548548
int evalDepth; /* Current eval depth */

0 commit comments

Comments
 (0)