Correctly detect infinite recursion in function application
If we're evaluating some application ‘v = f x’, we can't store ‘f’
temporarily in ‘v’, because if ‘f x’ refers to ‘v’, it will get ‘f’
rather than an infinite recursion error.
Unfortunately, this breaks the tail call optimisation introduced in
c897bac549
.
Fixes #217.
This commit is contained in:
parent
29cde917fe
commit
c9f6232304
1 changed files with 4 additions and 2 deletions
|
@ -779,8 +779,10 @@ void ExprLambda::eval(EvalState & state, Env & env, Value & v)
|
|||
|
||||
void ExprApp::eval(EvalState & state, Env & env, Value & v)
|
||||
{
|
||||
e1->eval(state, env, v);
|
||||
state.callFunction(v, *(e2->maybeThunk(state, env)), v);
|
||||
/* FIXME: vFun prevents GCC from doing tail call optimisation. */
|
||||
Value vFun;
|
||||
e1->eval(state, env, vFun);
|
||||
state.callFunction(vFun, *(e2->maybeThunk(state, env)), v);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue