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 expectation broken while playing with tutorial #5949

Open
yasuiniko opened this issue Nov 3, 2023 · 2 comments
Open

Compiler expectation broken while playing with tutorial #5949

yasuiniko opened this issue Nov 3, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@yasuiniko
Copy link

Error message

 % roc dev
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
thread 'main' panicked at 'region @17-49 not in list of dbgs', /Users/m1ci/actions-runner2/_work/roc/roc/crates/repl_expect/src/run.rs:521:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Device info

  • M1 pro chip running macOS 14.0
  • roc nightly pre-release, built from commit 849296a on Wed Nov 1 09:19:44 UTC 2023

Reproduction

The problem is caused by the dbg call on line 23 of the following code snippet, which I modified from the tutorial. I ran the code using roc dev.

## This is a comment for documentation, and includes a code block.
##
##     x = 2
##     expect x == 2
app "hello"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" }
    imports [pf.Stdout]
    provides [main] to pf

birds = 3

iguanas = -2

total = birds + iguanas

isAre = pluralize "is" "are" total

animalS = pluralize "animal" "animals" total

totalCount = stringify total

pluralize = \singular, plural, count ->
    dbg Pluralize "'count' is: \(Num.toStr count)"

    if count == 1 then
        singular
    else
        plural

stringify = \num ->
    if num == 0 then
        "no"
    else if num < 0 then
        "negative"
    else
        Num.toStr num

main =
    Stdout.line "There \(isAre) \(totalCount) \(animalS).\n\(Num.toStr birds) birds and \(Num.toStr iguanas) iguanas."
@lukewilliamboswell
Copy link
Collaborator

Thank you for logging this issue @yasuiniko. I assume you figured out that if you remove the tag then it works correctly?

dbg can only accept 1 argument. Roc should provide a helpful error message. I suspect that #5775 will resolve this issue as this will be a function call and provide a helpful error message.

Below is a smaller repro.

 roc dev broken.roc
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
thread 'main' panicked at 'region @17-9 not in list of dbgs', /Users/luke/Documents/GitHub/roc/crates/repl_expect/src/run.rs:521:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
app "hello"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" }
    imports [pf.Stdout]
    provides [main] to pf

foo : {} -> Str
foo = \_ ->
    dbg Tag ""
    
    "foo"

main = Stdout.line (foo {})

@lukewilliamboswell lukewilliamboswell added the bug Something isn't working label Nov 3, 2023
@yasuiniko
Copy link
Author

Thanks for the quick response and advice!

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