roc icon indicating copy to clipboard operation
roc copied to clipboard

Bad error msg when using `?` in the repl

Open shawsa opened this issue 4 months ago • 1 comments

Was experimenting in the repl and encountered this error.

[sage@sage-laptop-arch linalg]$ roc repl

  The rockin' roc repl
────────────────────────

Enter an expression, or :help, or :q to quit.

» test = [1, 2, 3]

[1, 2, 3] : List (Num *)
» List.first(test)?
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>
single register layouts are not complex symbols
Location: crates/compiler/gen_dev/src/generic64/x86_64.rs:355:17

This doesn't seem to happen when I compile the same thing so maybe something wrong with the repl?

shawsa avatar Oct 18 '25 00:10 shawsa

Hi @shawsa, Thanks for reporting this issue! The error message is indeed not helpful here, what it should roughly say is that you should only use ? in functions that return a Result. See also this example for a full breakdown.

So here you want to do just List.first(test). In the repl, to do something with the Ok value (1) coming out of List.first you can do for example: List.first(test) |> Result.map_ok(|x| x + 1).

I'll keep this issue open to make sure we provide a nice error message for this situation in the new compiler.

Anton-4 avatar Oct 18 '25 08:10 Anton-4