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

Nested question mark causes compiler crash #7049

Open
isaacvando opened this issue Sep 2, 2024 · 1 comment
Open

Nested question mark causes compiler crash #7049

isaacvando opened this issue Sep 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@isaacvando
Copy link
Sponsor Collaborator

This code causes the compiler to crash with the following error on roc check or roc test.

module []

isBomb : List Str, I64, I64 -> Result Bool [OutOfBounds]
isBomb = \rows, nx, ny ->
    rows
    |> List.get? (Num.toU64Checked? ny)
    |> Str.toUtf8
    |> List.get? (Num.toU64Checked? nx)
    |> Bool.isEq '*'
    |> Ok
$ roc check .meta/Example.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>
a Expr::TrySuffix expression was not completely removed in desugar_value_def_suffixed
Location: crates/compiler/can/src/expr.rs:1125:40

Extracting the nested ? expressions prevents the crash:

isBomb : List Str, I64, I64 -> Result Bool [OutOfBounds]
isBomb = \rows, nx, ny ->
    y = Num.toU64Checked? ny
    x = Num.toU64Checked? nx
    rows
    |> List.get? y
    |> Str.toUtf8
    |> List.get? x
    |> Bool.isEq '*'
    |> Ok
@ageron
Copy link
Contributor

ageron commented Sep 2, 2024

I think the compiler panics when there's more than one ? in an expression.

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