halgari/clojure-py — Issue #45: A combination of range, loop/recur and rest blows up the stack
Author: nathell
Created: 2012-03-09 16:50:42+00:00
State: open

Consider this code:

(loop [coll nil q () s (range 3)]
(if (empty? s)
coll
(recur
(cons
(concat (rest s) q)
coll)
(cons (first s) q)
(next s))))

It works in Clojure, returning `((1 0) (2 0) (1 2))`. In clojure-py, it causes a stack overflow error. It does, however, work if you replace `(range 3)` with `[0 1 2]`, or `(concat (rest s) q)` with `(concat s q)`.