Skip to content

be is not stack safe #10

@paulyoung

Description

@paulyoung

I'm seeing RangeError: Maximum call stack size exceeded inside of this function.

be :: Int -> Int -> List (Tuple Int DOC) -> Doc
be w k List.Nil = Nil
be w k (Cons (Tuple i NIL) z) = be w k z
be w k (Cons (Tuple i (APPEND x y)) z) = be w k $ (Tuple i x) : (Tuple i y) : z
be w k (Cons (Tuple i (NEST j x)) z) = be w k $ (Tuple (i + j) x) : z
be w k (Cons (Tuple i (TEXT s)) z) = Text s $ be w (k + String.length s) z
be w k (Cons (Tuple i LINE) z) = Line i $ be w i z
be w k (Cons (Tuple i (UNION x y)) z) =
let x' = be w k $ (Tuple i x) : z
in if fits (w - k) x' then x' else be w k $ (Tuple i y) : z

It's not exported so hopefully this can be addressed without any breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions