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: Using an undefined Int variable with Inspect.toStr #7191

Open
dxrcy opened this issue Oct 29, 2024 · 0 comments
Open

Compiler bug: Using an undefined Int variable with Inspect.toStr #7191

dxrcy opened this issue Oct 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dxrcy
Copy link

dxrcy commented Oct 29, 2024

foo : Int I32

main =
    _ = Inspect.toStr foo
    Task.ok {}
An internal compiler expectation was broken.
[...]
ambient functions don't unify
Location: crates/compiler/unify/src/unify.rs:202:18
foo : Num *

main =
    _ = Inspect.toStr 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: `15.IdentId(5)`, 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.

roc check only warns about the _ = ... part.

Qualifying number kind X as Num X does not affect the result, and neither does converting X to List X.

Changing foo to a Str, Bool, Frac *, Dec * or List Str prevents the compiler bug, and it throws a runtime error NoImplementationNamed (which appears to be intended behaviour).

Similarly, using Num.toStr or another function also throws NoImplementationNamed.

This makes me think that it is specifically an issue with Num and Inspect.toStr....

@dxrcy dxrcy changed the title Compiler bug: Using an undefined variable with Inspect.toStr Compiler bug: Using an undefined Int variable with Inspect.toStr Oct 29, 2024
@Anton-4 Anton-4 added the bug Something isn't working label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants