From 5a383a288d620b9ae6111d9f33b9e420d3fcd0f8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 13 May 2015 20:13:29 -0700 Subject: Recursive lcons force bug (keep-if*, remove-if*). * lib.c (rem_lazy_func): Do not access the cdr field of the lcons that we are in the middle of forcing! --- lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index a1dd429e..28e58240 100644 --- a/lib.c +++ b/lib.c @@ -1153,7 +1153,9 @@ static val rem_lazy_rec(val obj, val list, val env, val func); static val rem_lazy_func(val env, val lcons) { cons_bind (pred, list, env); - return cdr(rplacd(lcons, rem_lazy_rec(pred, list, env, lcons_fun(lcons)))); + val rest = rem_lazy_rec(pred, list, env, lcons_fun(lcons)); + rplacd(lcons, rem_lazy_rec(pred, list, env, lcons_fun(lcons))); + return rest; } static val rem_lazy_rec(val pred, val list, val env, val func) -- cgit v1.2.3