Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling a Module function which depends on an Effectful module param inside Task.loop causes compiler panic #7116

Open
imclerran opened this issue Sep 24, 2024 · 2 comments

Comments

@imclerran
Copy link

imclerran commented Sep 24, 2024

Error message:

thread 'main' panicked at crates/compiler/mono/src/borrow.rs:396:34:
internal error: entered unreachable code: 
        No borrow signature for LambdaName { name: `35.IdentId(0)`, niche: Niche(Captures([])) } layout.

        Tip 1: This can happen when you call a function with less arguments than it expects.
        Like `Arg.list!` instead of `Arg.list! {}`.

                            Tip 2: `roc check yourfile.roc` can sometimes give you a helpful error. 
                            
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Minimum reproduction:

app [main] {
    cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br",
}

import Module { task: (Task.ok {}) }

main = Task.loop! {} loop

loop = \{} -> Task.ok (Step  Module.effect!)
module { task } -> [effect]

effect = task
@imclerran
Copy link
Author

One additional finding: inlining the loop function eliminates the panic.

So the following will not cause the bug:

main = Task.loop! {} \{} -> Task.ok (Step Module.effect!)

@imclerran
Copy link
Author

Linking to Zulip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant