mfikes/ambly

Hang if stack overflow

mfikes opened this issue · 0 comments

(This ticket is inspired by blog post of Stuart Sierra.)

(defn next-results
  "Placeholder for function which computes some intermediate
  collection of results."
  [n]
  (range 1 n))

(defn build-result [n]
  (loop [counter 1
         results []]
    (if (< counter n)
      (recur (inc counter)
             (concat results (next-results counter)))
      results)))
cljs.user=> (first (build-result 4000))
RangeError: Maximum call stack size exceeded.

The stack overflow is reported, but the REPL then hangs.