Skip to content

Commit cfcc504

Browse files
sticky tail call bugs with user-defined closures
1 parent 64dfd89 commit cfcc504

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ulisp.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,11 +1805,13 @@ object* apply (object* function, object* args, object* env) {
18051805
}
18061806
if (consp(function) && isbuiltin(car(function), LAMBDA)) {
18071807
object* result = closure(false, sym(NIL), function, args, &env);
1808+
clrflag(TAILCALL);
18081809
return eval(result, env);
18091810
}
18101811
if (consp(function) && isbuiltin(car(function), CLOSURE)) {
18111812
function = cdr(function);
18121813
object* result = closure(false, sym(NIL), function, args, &env);
1814+
clrflag(TAILCALL);
18131815
return eval(result, env);
18141816
}
18151817
error("illegal function", function);
@@ -6045,7 +6047,8 @@ object* macroexpand1 (object* form, object* env, bool* done) {
60456047
}
60466048
while (symbolp(car(form))) form = cons(cdr(findvalue(car(form), env)), cdr(form));
60476049
protect(form);
6048-
form = closure(0, sym(NIL), car(form), cdr(form), &env);
6050+
form = closure(false, sym(NIL), car(form), cdr(form), &env);
6051+
clrflag(TAILCALL);
60496052
object* result = eval(form, env);
60506053
unprotect();
60516054
return result;
@@ -7419,6 +7422,7 @@ object* eval (object* form, object* env) {
74197422

74207423
if (isbuiltin(car(function), LAMBDA)) {
74217424
form = closure(old_tailcall, name, function, args, &env);
7425+
clrflag(TAILCALL);
74227426
unprotect();
74237427
int trace = tracing(fname->name);
74247428
if (trace) {
@@ -7439,6 +7443,7 @@ object* eval (object* form, object* env) {
74397443
function = cdr(function);
74407444
form = closure(old_tailcall, name, function, args, &env);
74417445
unprotect();
7446+
clrflag(TAILCALL);
74427447
tailcall = true;
74437448
goto EVAL;
74447449
}

0 commit comments

Comments
 (0)