Skip to content

Commit

Permalink
Fix crash when returning from "method not found" break loop
Browse files Browse the repository at this point in the history
Fixes #2447
  • Loading branch information
fingolfin committed May 9, 2018
1 parent 5a3ffa8 commit cf61a22
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/opers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2115,10 +2115,6 @@ static ALWAYS_INLINE Obj DoOperationNArgs(Obj oper,
CacheMethod(oper, n, prec, ids, method);
}

if (!method) {
ErrorQuit("no method returned", 0L, 0L);
}

/* If there was no method found, then pass the information needed
for the error reporting. This function rarely returns */
if (method == Fail) {
Expand Down Expand Up @@ -2149,6 +2145,10 @@ static ALWAYS_INLINE Obj DoOperationNArgs(Obj oper,
verbose, constructor, INTOBJ_INT(prec));
}

if (!method) {
ErrorQuit("no method returned", 0L, 0L);
}

/* call this method */
switch (n) {
case 0:
Expand Down
3 changes: 3 additions & 0 deletions tst/test-error/method-not-found.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# test returning from a 'method not found' error
f:=a->a+a;; f(());
return;
15 changes: 15 additions & 0 deletions tst/test-error/method-not-found.g.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
gap> # test returning from a 'method not found' error
gap> f:=a->a+a;; f(());
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `+' on 2 arguments at GAPROOT/lib/methsel2.g:250 called from
a + a at *stdin*:3 called from
<function "f">( <arguments> )
called from read-eval loop at *stdin*:3
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> return;
Error, no method returned in
return a + a; at *stdin*:3 called from
<function "f">( <arguments> )
called from read-eval loop at *stdin*:3
gap> QUIT;

0 comments on commit cf61a22

Please sign in to comment.