Stream: beginners

Topic: Internal error: entered unreachable code: no borrow signat..


view this post on Zulip Jamie Neubert Pedersen (Jul 09 2024 at 20:01):

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)

view this post on Zulip Kiryl Dziamura (Jul 09 2024 at 20:29):

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

view this post on Zulip Brendan Hansknecht (Jul 09 2024 at 22:04):

I think you need Task.forever or Task.loop today to workaround these compiler bugs

view this post on Zulip Brendan Hansknecht (Jul 09 2024 at 22:04):

Recursive tasks due to how we compile effects can break the compiler

view this post on Zulip Brendan Hansknecht (Jul 09 2024 at 22:05):

This is a nice minimal repro though

view this post on Zulip Brendan Hansknecht (Jul 09 2024 at 22:05):

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)"

view this post on Zulip Jamie Neubert Pedersen (Jul 10 2024 at 04:13):

@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