Skip to content

Commit

Permalink
When printing function, reproduce TryNextMethod() correctly
Browse files Browse the repository at this point in the history
Before:
gap> Display(function() TryNextMethod(); end);
function (  )
    return TRY_NEXT_METHOD;
end

After:
gap> Display(function() TryNextMethod(); end);
function (  )
    TryNextMethod();
end
  • Loading branch information
fingolfin committed Aug 22, 2017
1 parent d9d4c4b commit 4cd28c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,9 +2241,16 @@ void PrintAssert3Args (
void PrintReturnObj (
Stat stat )
{
Pr( "%2>return%< %>", 0L, 0L );
PrintExpr( ADDR_STAT(stat)[0] );
Pr( "%2<;", 0L, 0L );
Expr expr = ADDR_STAT(stat)[0];
if ( TNUM_EXPR(expr) == T_REF_GVAR &&
(UInt)(ADDR_STAT(expr)[0]) == GVarName( "TRY_NEXT_METHOD" ) ) {
Pr( "TryNextMethod();", 0L, 0L );
}
else {
Pr( "%2>return%< %>", 0L, 0L );
PrintExpr( expr );
Pr( "%2<;", 0L, 0L );
}
}


Expand Down
8 changes: 8 additions & 0 deletions tst/testinstall/function.tst
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,12 @@ gap> Display(x->x);
function ( x )
return x;
end

#
gap> Display(function() TryNextMethod(); end);
function ( )
TryNextMethod();
end

#
gap> STOP_TEST("function.tst", 1);

0 comments on commit 4cd28c8

Please sign in to comment.