coalton-lang / coalton

Coalton is an efficient, statically typed functional programming language that supercharges Common Lisp.
https://coalton-lang.github.io/
MIT License
1.15k stars 70 forks source link

`Into (Vector :a) (List :a)` triggers stack overflows at large vector sizes #1106

Closed Izaakwltn closed 5 months ago

Izaakwltn commented 5 months ago
(coalton-toplevel

  ;; stack overflows
  (define (numvec->numlist)
    (let v = (vec:new))
    (iter:for-each! (fn (x)
                      (vec:push! x v)
                      Unit)
                    (iter:up-to 10000))
    (The (List Integer) (into v)))

  ;; potential alternative, does not overflow
  (define (numvec->numlist2)
    (let v = (vec:new))
    (iter:for-each! (fn (x)
                      (vec:push! x v)
                      Unit)
                    (iter:up-to 10000))
    (The (List Integer) (iter:collect! (iter:into-iter v)))))