diff options
| author | Mistivia <i@mistivia.com> | 2025-06-21 20:20:12 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-21 20:23:24 +0800 |
| commit | 1cf7adef90777698d1f17363a5f82c997d5f1c34 (patch) | |
| tree | ae10b7efd3dc3d20a4f798849b5edaf1a31cc47f /src/interp.c | |
| parent | 249700617406474c5b60df2aa66a2a9951603e3c (diff) | |
fix tco bug
Diffstat (limited to 'src/interp.c')
| -rw-r--r-- | src/interp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/interp.c b/src/interp.c index a99440c..df995ca 100644 --- a/src/interp.c +++ b/src/interp.c @@ -674,7 +674,7 @@ SExpRef lisp_eval(Interp *interp, SExpRef sexp, bool istail) { LispPrimitive primitive_fn = PrimitiveEntryVector_ref(&interp->primitives, i)->fn; ret = (*primitive_fn)(interp, CDR(sexp), istail); - if (VALTYPE(ret) == kTailcallSExp) { + if (VALTYPE(ret) == kTailcallSExp && !istail) { fn = REF(ret)->tailcall.fn; args = REF(ret)->tailcall.args; goto tailcall; @@ -693,7 +693,7 @@ SExpRef lisp_eval(Interp *interp, SExpRef sexp, bool istail) { PUSH_REG(funcallargs); ret = primitive_funcall(interp, funcallargs, istail); POP_REG(); - if (VALTYPE(ret) == kTailcallSExp) { + if (VALTYPE(ret) == kTailcallSExp && !istail) { fn = REF(ret)->tailcall.fn; args = REF(ret)->tailcall.args; goto tailcall; |
