From 02e8b343c79c4fbcfedc8b703f7f75368a1e39ea Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sat, 2 Jul 2016 02:42:32 -0400 Subject: [PATCH] Fix Cyc_has_cycle to compare cons cells Compare the cons cells themselves - instead of values - to determine if there is a cycle. By definition the pointers will be different unless there is a cycle. --- runtime.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/runtime.c b/runtime.c index f01e6c56..75ccca58 100644 --- a/runtime.c +++ b/runtime.c @@ -540,9 +540,7 @@ object Cyc_has_cycle(object lst) return boolean_f; if (Cyc_is_pair(cdr(fast_lst)) == boolean_f) return boolean_f; - if (is_object_type(car(slow_lst)) && boolean_f == Cyc_is_boolean(car(slow_lst)) && // Avoid expected dupes - //boolean_f == Cyc_is_symbol(car(slow_lst)) && // - (car(slow_lst) == car(fast_lst))) + if (slow_lst == fast_lst) return boolean_t; slow_lst = cdr(slow_lst);