Hi there. I have a very small recursive program that gives a compiler error:
$ roc dev ./src/main.roc
thread 'main' panicked at crates/compiler/mono/src/borrow.rs:396:33:
internal error: entered unreachable code: no borrow signature for LambdaName { name: `40.IdentId(4)`, niche: Niche(Captures([])) } layout
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The program is included here:
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
}
import pf.Stdout
import pf.Stdin
import pf.Task
main =
runPrompt
run = \input ->
execute input
runPrompt =
Stdout.write! "Give me input: "
input = Stdin.line!
_ = run input
runPrompt
execute = \input ->
Stdout.line! "You gave me: $(input)"
Does anyone know what is going on here?
(And essentially what I want to be able to do is run the program forever until the user stops giving new prompts by sending a stop signal with CTRL+c or the likes)
At first glance it lacks !
after run
, so it’s _ = run! input
but it's probably not connected with the error. Can’t check right now
I think you need Task.forever or Task.loop today to workaround these compiler bugs
Recursive tasks due to how we compile effects can break the compiler
This is a nice minimal repro though
A fixed version:
main =
Task.forever runPrompt
run = \input ->
execute input
runPrompt =
Stdout.write! "Give me input: "
input = Stdin.line!
run! input
execute = \input ->
Stdout.line! "You gave me: $(input)"
@Kiryl Dziamura Thanks, but yeah it didn't fix the error.
@Brendan Hansknecht thank you for the information and the version that works :+1:
Last updated: Jul 06 2025 at 12:14 UTC