-
Notifications
You must be signed in to change notification settings - Fork 181
Error handling: split stack frames over two lines; adjust more manual examples #6263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
011dec8
04e6294
4a0e38f
bbe95f1
6cc08be
6b15d58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -915,41 +915,33 @@ to terminate the calculation, or enter <B>Return</B><C>;</C> to continue it. | |
| gap> dive:= function(depth) if depth>1 then dive(depth-1); fi; return; end; | ||
| function( depth ) ... end | ||
| gap> dive(100); | ||
| gap> OnBreak:= function() Where(1); end; # shorter traceback | ||
| function( ) ... end | ||
| gap> OnBreak:= function() Where(2); end;; # shorter traceback | ||
| gap> dive(6000); | ||
| recursion depth trap (5000) | ||
| at | ||
| dive( depth - 1 ); | ||
| called from | ||
| dive( depth - 1 ); called from | ||
| ... | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you may 'return;' to continue | ||
| Error, recursion depth trap (5000) | ||
| *[1] dive( depth - 1 ); | ||
| @ *stdin*:1 | ||
| [2] dive( depth - 1 ); | ||
| @ *stdin*:1 | ||
| ... at *stdin*:4 | ||
| you may 'return;' | ||
| brk> return; | ||
| gap> dive(11000); | ||
| recursion depth trap (5000) | ||
| at | ||
| dive( depth - 1 ); | ||
| called from | ||
| dive( depth - 1 ); called from | ||
| ... | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you may 'return;' to continue | ||
| Error, recursion depth trap (5000) | ||
| *[1] dive( depth - 1 ); | ||
| @ *stdin*:1 | ||
| [2] dive( depth - 1 ); | ||
| @ *stdin*:1 | ||
| ... at *stdin*:5 | ||
| you may 'return;' | ||
| brk> return; | ||
| recursion depth trap (10000) | ||
| at | ||
| dive( depth - 1 ); | ||
| called from | ||
| dive( depth - 1 ); called from | ||
| ... | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you may 'return;' to continue | ||
| brk> return; | ||
| gap> | ||
| Error, recursion depth trap (10000) | ||
| *[1] dive( depth - 1 ); | ||
| @ *stdin*:1 | ||
| [2] dive( depth - 1 ); | ||
| @ *stdin*:1 | ||
| ... at *stdin*:5 | ||
| you may 'return;' | ||
| brk> return;gap> | ||
| ]]></Log> | ||
| <P/> | ||
|
|
||
|
|
@@ -979,39 +971,29 @@ gap> dive := function(depth) | |
| > fi; | ||
| > end;; | ||
| gap> SetRecursionTrapInterval(1000); | ||
| gap> OnBreak:= function() Where(2); end;; # shorter traceback | ||
| gap> dive(100); | ||
| Depth 100 | ||
| gap> dive(2500); | ||
| recursion depth trap (1000) | ||
| at | ||
| dive( depth - 1 ); | ||
| called from | ||
| dive( depth - 1 ); called from | ||
| ... | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you may 'return;' to continue | ||
| Error, recursion depth trap (1000) | ||
| *[1] dive( depth - 1 ); | ||
| @ *stdin*:4 | ||
| [2] dive( depth - 1 ); | ||
| @ *stdin*:4 | ||
| ... at *stdin*:12 | ||
| you may 'return;' | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually I think one still can
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its a bug, but I am sure its not cause but this PR as well and its irrelevant to the changes.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just checked: in GAP 4.4 it still printed: but starting with 4.5, the "quit" line was gone. I think I know why (certain changes to kernel error handling), but am too lazy to dig up the exact commit: it'll not be in the public history anyway, plus I don't see a point: clearly we want to show this info, yet error handling has substantially changed since then, so we are better of just adding it back now without caring how it used to be done. I'll do that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is not so small, so for now I filed an issue, let's focus on the rest of this PR first.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. |
||
| brk> return; | ||
| recursion depth trap (2000) | ||
| at | ||
| dive( depth - 1 ); | ||
| called from | ||
| dive( depth - 1 ); called from | ||
| ... | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you may 'return;' to continue | ||
| Error, recursion depth trap (2000) | ||
| *[1] dive( depth - 1 ); | ||
| @ *stdin*:4 | ||
| [2] dive( depth - 1 ); | ||
| @ *stdin*:4 | ||
| ... at *stdin*:12 | ||
| you may 'return;' | ||
| brk> GetRecursionDepth(); | ||
| 0 | ||
| brk> return; | ||
| gap> SetRecursionTrapInterval(-1); | ||
| Error, SetRecursionTrapInterval: <interval> must be a small integer greater than 5 (n\ | ||
| ot the integer -1) | ||
| not in any function | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you can replace <interval> via 'return <interval>;' to continue | ||
| brk> return 0; | ||
| gap> SetRecursionTrapInterval(2^50); | ||
| gap> dive(20000); | ||
| Depth 20000 | ||
| gap> dive(2000000); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -652,11 +652,7 @@ gap> h:=Group(permutationlist); | |
| <permutation group with 5 generators> | ||
| gap> StabChainOptions(h).random:=1;; | ||
| gap> Size(h); | ||
| exceeded the permitted memory (`-o' command line option) at | ||
| mlimit := 1; called from | ||
| SCRMakeStabStrong( S.stabilizer, [ g ], param, orbits, where, basesize, | ||
| base, correct, missing, false ); called from | ||
| SCRMakeStabStrong( S.stabilizer, [ g ], param, orbits, where, basesize, | ||
| exceeded the permitted memory (`-o' command line option) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to drop the stacktrace: the example can't be reproduced (missing inputs) but it is also irrelevant for the point this section is trying to make |
||
| ... | ||
| ]]></Log> | ||
| <P/> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1556,24 +1556,19 @@ If the expression <A>expr</A> is a function call then this function must | |
| return a value. If the function does not return a value an error is | ||
| signalled and you enter a break loop (see <Ref Sect="Break Loops"/>). | ||
| As usual you can leave the break loop with <C>quit;</C>. | ||
| If you enter <C>return <A>return-expr</A>;</C> the value of the expression | ||
| <A>return-expr</A> is assigned to the variable, | ||
| and execution continues after the assignment. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was straight out wrong (we removed this capability years ago as it seemed to be only a source of grief) |
||
| <P/> | ||
| <Log><![CDATA[ | ||
| gap> f1:= function( x ) Print( "value: ", x, "\n" ); end;; | ||
| gap> f2:= function( x ) return f1( x ); end;; | ||
| gap> f2( 4 ); | ||
| value: 4 | ||
| Function Calls: <func> must return a value at | ||
| return f1( x ); | ||
| called from | ||
| <function>( <arguments> ) called from read-eval-loop | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you can supply one by 'return <value>;' to continue | ||
| brk> return "hello"; | ||
| "hello" | ||
| Error, Function Calls: <func> must return a value | ||
| *[1] f1( x ) | ||
| @ *stdin*:2 | ||
| <function "f2">( <arguments> ) | ||
| called from read-eval loop at *stdin*:3 | ||
| type 'quit;' to quit to outer loop | ||
| brk> | ||
| ]]></Log> | ||
| <P/> | ||
| In the above example, the function <C>f2</C> calls <C>f1</C> with argument | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -476,24 +476,20 @@ indicate that you are in a break loop. | |
| <P/> | ||
| <Log><![CDATA[ | ||
| gap> 1/0; | ||
| Rational operations: <divisor> must not be zero | ||
| not in any function | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you can replace <divisor> via 'return <divisor>;' to continue | ||
| Error, Rational operations: <divisor> must not be zero | ||
| not in any function at *stdin*:2 | ||
| type 'quit;' to quit to outer loop | ||
| ]]></Log> | ||
| <P/> | ||
| If errors occur within a break loop &GAP; enters another break loop at a | ||
| <E>deeper level</E>. This is indicated by a number appended to <C>brk</C>: | ||
| <P/> | ||
| <Log><![CDATA[ | ||
| brk> 1/0; | ||
| Rational operations: <divisor> must not be zero | ||
| not in any function | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you can replace <divisor> via 'return <divisor>;' to continue | ||
| brk_02> | ||
| Error, Rational operations: <divisor> must not be zero | ||
| not in any function at *stdin*:2 | ||
| type 'quit;' to quit to outer loop | ||
| brk_2> | ||
| ]]></Log> | ||
| <P/> | ||
| There are two ways to leave a break loop, | ||
|
|
@@ -511,7 +507,7 @@ Note that &GAP; code between <C>quit;</C> and the end of the input line | |
| is ignored. | ||
| <P/> | ||
| <Log><![CDATA[ | ||
| brk_02> quit; | ||
| brk_2> quit; | ||
| brk> | ||
| ]]></Log> | ||
| <P/> | ||
|
|
@@ -750,25 +746,30 @@ same as <Ref Func="Where"/> while also showing the arguments and local | |
| variables of each function. | ||
| <P/> | ||
| <Log><![CDATA[ | ||
| gap> StabChain(SymmetricGroup(100)); # After this we typed ^C | ||
| user interrupt at | ||
| bpt := S.orbit[1]; | ||
| called from | ||
| SiftedPermutation( S, (g * rep) ^ -1 ) called from | ||
| StabChainStrong( S.stabilizer, [ sch ], options ); called from | ||
| StabChainStrong( S.stabilizer, [ sch ], options ); called from | ||
| StabChainStrong( S, GeneratorsOfGroup( G ), options ); called from | ||
| StabChainOp( G, rec( | ||
| ) ) called from | ||
| ... | ||
| Entering break read-eval-print loop ... | ||
| you can 'quit;' to quit to outer loop, or | ||
| you can 'return;' to continue | ||
| gap> StabChain(SymmetricGroup(1000)); # After this we typed ^C | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. had to go from 100 to 1000 as I otherwise couldn't press Ctrl-C quickly enough 😁
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would resolve that too. |
||
| Error, user interrupt | ||
| *[1] genlabels := Filtered( genlabels, function ( x ) | ||
| return pnt ^ sgs[x] = pnt; | ||
| end ); | ||
| @ GAPROOT/lib/stbc.gi:426 | ||
| [2] StabChainBaseStrongGenerators( dom{[ 1 .. Length( dom ) - 1 ]}, sgs, () ) | ||
| @ GAPROOT/lib/gpprmsya.gi:2006 | ||
| [3] StabChainOp( G, rec( | ||
| ) ) | ||
| @ GAPROOT/lib/stbc.gi:28 | ||
| [4] StabChainImmutable( arg[1] ) | ||
| @ GAPROOT/lib/stbc.gi:18 | ||
| <function "StabChain">( <arguments> ) | ||
| called from read-eval loop at *stdin*:2 | ||
| you can 'return;' | ||
| brk> Where(2); | ||
| called from | ||
| SiftedPermutation( S, (g * rep) ^ -1 ) called from | ||
| StabChainStrong( S.stabilizer, [ sch ], options ); called from | ||
| ... | ||
| *[1] genlabels := Filtered( genlabels, function ( x ) | ||
| return pnt ^ sgs[x] = pnt; | ||
| end ); | ||
| @ GAPROOT/lib/stbc.gi:426 | ||
| [2] StabChainBaseStrongGenerators( dom{[ 1 .. Length( dom ) - 1 ]}, sgs, () ) | ||
| @ GAPROOT/lib/gpprmsya.gi:2006 | ||
| ... at *errin*:1 | ||
| ]]></Log> | ||
| <P/> | ||
| Note that the variables displayed even in the first line of the | ||
|
|
@@ -836,10 +837,14 @@ Error, ! | |
| you can 'quit;' to quit to outer loop, or | ||
| you can 'return;' to continue | ||
| brk> Where(); | ||
| *[1] Error( "!\n" ); at *stdin*:3 called from | ||
| [2] test( n + 1 ); at *stdin*:3 called from | ||
| [3] test( n + 1 ); at *stdin*:3 called from | ||
| [4] test( n + 1 ); at *stdin*:3 called from | ||
| *[1] Error( "!\n" ); | ||
| @ *stdin*:4 | ||
| [2] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| [3] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| [4] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| <function "test">( <arguments> ) | ||
| called from read-eval loop at *errin*:1 | ||
| brk> n; | ||
|
|
@@ -848,20 +853,28 @@ brk> DownEnv(); | |
| brk> n; | ||
| 3 | ||
| brk> Where(); | ||
| [1] Error( "!\n" ); at *stdin*:3 called from | ||
| *[2] test( n + 1 ); at *stdin*:3 called from | ||
| [3] test( n + 1 ); at *stdin*:3 called from | ||
| [4] test( n + 1 ); at *stdin*:3 called from | ||
| [1] Error( "!\n" ); | ||
| @ *stdin*:4 | ||
| *[2] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| [3] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| [4] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| <function "test">( <arguments> ) | ||
| called from read-eval loop at *errin*:5 | ||
| brk> DownEnv( 2 ); | ||
| brk> n; | ||
| 1 | ||
| brk> Where(); | ||
| [1] Error( "!\n" ); at *stdin*:3 called from | ||
| [2] test( n + 1 ); at *stdin*:3 called from | ||
| [3] test( n + 1 ); at *stdin*:3 called from | ||
| *[4] test( n + 1 ); at *stdin*:3 called from | ||
| [1] Error( "!\n" ); | ||
| @ *stdin*:4 | ||
| [2] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| [3] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| *[4] test( n + 1 ); | ||
| @ *stdin*:4 | ||
| <function "test">( <arguments> ) | ||
| called from read-eval loop at *errin*:8 | ||
| brk> DownEnv( -2 ); | ||
|
|
@@ -894,10 +907,13 @@ gap> fun := function() local x; x := 3; bar(); end; | |
| function( ) ... end | ||
| gap> fun(); | ||
| Error, !! | ||
| called from | ||
| bar( ); called from | ||
| <function>( <arguments> ) called from read-eval-loop | ||
| Entering break read-eval-print loop ... | ||
| Stack trace: | ||
| *[1] Error( "!!\n" ); | ||
| @ *stdin*:4 | ||
| [2] bar( ); | ||
| @ *stdin*:7 | ||
| <function "fun">( <arguments> ) | ||
| called from read-eval loop at *stdin*:8 | ||
| you can 'quit;' to quit to outer loop, or | ||
| you can 'return;' to continue | ||
| brk> x; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "1" showed 2 level due to a bug that I fixed in #6257, so I've now changed it to 2 levels to more closely match was the example showed before