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

Compiler bug: 'I thought a non-nullable-unwrapped variant for a lambda set was impossible' #7183

Open
dxrcy opened this issue Oct 25, 2024 · 1 comment
Labels
bug Something isn't working P-high High priority/frequency

Comments

@dxrcy
Copy link

dxrcy commented Oct 25, 2024

Possibly related to (or duplicate of) #6252.

When compiling a recursive function with a particular type signature.
On EndevourOS (Arch Linux), x86_64, roc nightly pre-release, built from commit 71e68f9 on Mi 23 Okt 2024 09:02:05 UTC.

Most minimal reproducible example I could find, shown below.
Note the {} parameter and the Task return is required.
roc check reports 0 errors and 0 warnings.

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

main : Task {} *
main =
    foo! {}

foo : {} -> Task {} *
foo = \{} ->
    foo! {}
    Task.ok {}
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
I thought a non-nullable-unwrapped variant for a lambda set was impossible: how could such a lambda set be created without a base case?
Location: crates/compiler/mono/src/layout.rs:1705:61

Removing the parameter on foo changes the error, as shown below. It is also caught by roc check.
I assume this error is less remarkable since it is marked as TODO.

main : Task {} *
main =
    foo! {}

foo : Task {} *
foo = \{} ->
    foo!
    Task.ok {}
thread '<unnamed>' panicked at crates/compiler/constrain/src/expr.rs:3706:22:
not yet implemented: TODO (@195-198 `17.IdentId(1)`, DelayedAlias { shared: Index(2) })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Removing the Task return value makes the program function as expected (an infinite loop with no output).

main : Task {} *
main =
    _ = foo {}
    Task.ok {}

foo : {} -> {}
foo = \{} ->
    _ = foo {}
    {}

...and similarly when changing the return value to Task * *

foo : {} -> Task * *
foo = \{} ->
    foo {}

Using two mutually-recursive functions causes another error.

foo : {} -> Task {} *
foo = \{} ->
    bar! {}
    Task.ok {}

bar : {} -> Task {} *
bar = \{} ->
    foo! {}
    Task.ok {}
thread 'main' panicked at crates/compiler/mono/src/borrow.rs:396:34:
internal error: entered unreachable code:
        No borrow signature for LambdaName { name: `17.IdentId(2)`, 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.

The tips don't seem to help; roc check again returns 0 errors and 0 warnings.
If this case is unrelated, I can create a separate issue for it.

@Anton-4 Anton-4 added bug Something isn't working P-high High priority/frequency labels Oct 25, 2024
@Anton-4
Copy link
Collaborator

Anton-4 commented Oct 25, 2024

Thanks for the detailed error report @dxrcy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-high High priority/frequency
Projects
None yet
Development

No branches or pull requests

2 participants