roc
roc copied to clipboard
Stack overflow during compilation
I was working on implementing a web service and encountered a reproducible stack overflow.
$ roc check
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow
zsh: IOT instruction (core dumped) roc check
The (seemingly) relevant section of the file was:
processRequest : App -> (Request -> Task Response [])
processRequest = \app -> \request ->
#preprocess = \req, middleware -> Task.await req middleware.preprocessRequest
postprocess = \resp, middleware -> Task.await resp middleware.postprocessResponse
handleRequest = \reqTask ->
Task.await reqTask \req ->
handler = app.router req
handler req
Task.ok request
#|> \req -> List.walk app.middleware req preprocess
|> handleRequest
|> \req -> List.walkBackwards app.middleware req postprocess
Uncommenting the 2 lines and compiling / roc check
causes the stack overflow. The full program is a single <200 line file and can be found here
Compiling the program with those 2 lines commented works.