prunedtree in IRC reported a stack overflow with this code:
http://paste.lisp.org/display/67882

I was able to trim this down and still reproduce the error:

(dorun (for [i (range 10000) j nil] 1))

It turns out that "for" and "lazy-cat" interact badly in this
degenerate case.  Having "for" use "recur" instead of "lazy-cat" in
such cases seems to fix the problem.  Patch is attached.

--Chouser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

diff --git a/src/clj/clojure/boot.clj b/src/clj/clojure/boot.clj
index 68cb448..30c8d68 100644
--- a/src/clj/clojure/boot.clj
+++ b/src/clj/clojure/boot.clj
@@ -2274,9 +2274,11 @@
 			 (when-first ~b ~gxs
                            (if ~f
 			    ~(if rses
-			       `(let [iterys# ~(emit rses)]
-				  (lazy-cat (iterys# ~ys)
-					    (~giter (rest ~gxs))))
+			       `(let [iterys# ~(emit rses)
+                                      fs# (iterys# ~ys)]
+                                  (if fs#
+				    (lazy-cat fs# (~giter (rest ~gxs)))
+                                    (recur (rest ~gxs))))
 			       `(lazy-cons ~expr (~giter (rest ~gxs))))
                             ~(if (= w :when)
                                `(recur (rest ~gxs))

Reply via email to