Skip to content

Commit

Permalink
kernel: insert a few SET_BRK_CALL_TO(stat) calls
Browse files Browse the repository at this point in the history
After evaluating the body of a loop resp. an if-statmeent, and before
evaluating the next condition expression, reset the current statement to
point to the loop resp. if-statement again.
  • Loading branch information
fingolfin committed Oct 4, 2018
1 parent 9ac7967 commit 58101f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ UInt ExecIfElse (

}

SET_BRK_CALL_TO(stat);

/* otherwise execute the else-branch body and leave */
body = READ_STAT(stat, 3);
return EXEC_STAT( body );
Expand Down Expand Up @@ -269,6 +271,7 @@ UInt ExecIfElif (

}

SET_BRK_CALL_TO(stat);
}

/* return 0 (to indicate that no leave-statement was executed) */
Expand Down Expand Up @@ -299,6 +302,7 @@ UInt ExecIfElifElse (

}

SET_BRK_CALL_TO(stat);
}

/* otherwise execute the else-branch body and leave */
Expand Down Expand Up @@ -689,6 +693,7 @@ static ALWAYS_INLINE UInt ExecWhileHelper(Stat stat, UInt nr)
if (nr >= 3)
EXEC_STAT_IN_LOOP(body3);

SET_BRK_CALL_TO(stat);
}

/* return 0 (to indicate that no leave-statement was executed) */
Expand Down Expand Up @@ -760,6 +765,8 @@ static ALWAYS_INLINE UInt ExecRepeatHelper(Stat stat, UInt nr)
if (nr >= 3)
EXEC_STAT_IN_LOOP(body3);

SET_BRK_CALL_TO(stat);

} while ( EVAL_BOOL_EXPR( cond ) == False );

/* return 0 (to indicate that no leave-statement was executed) */
Expand Down
10 changes: 8 additions & 2 deletions tst/testspecial/backtrace.g.out
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ gap>
gap> f:=function() if 1 < 0 then return 1; elif 1 then return 2; fi; return 3; end;;
gap> f();
Error, <expr> must be 'true' or 'false' (not a integer) in
1 < 0 at *stdin*:18 called from
if 1 < 0 then
return 1;
elif 1 then
return 2;
fi; at *stdin*:18 called from
<function "f">( <arguments> )
called from read-eval loop at *stdin*:19
you can replace <expr> via 'return <expr>;'
Expand Down Expand Up @@ -130,7 +134,9 @@ gap>
gap> f:=function() local x; repeat x:=1; until 1; return 2; end;;
gap> f();
Error, <expr> must be 'true' or 'false' (not a integer) in
x := 1; at *stdin*:30 called from
repeat
x := 1;
until 1; at *stdin*:30 called from
<function "f">( <arguments> )
called from read-eval loop at *stdin*:31
you can replace <expr> via 'return <expr>;'
Expand Down

0 comments on commit 58101f8

Please sign in to comment.