Hello, I'm getting a thread panic when running the following in my repl (M1 mac, on roc nightly pre-release, built from commit 943d7a3cdf on Fri Feb 16 09:13:04 UTC 2024
)
when List.get ["a", "b", "c"] index is
Ok str -> "I got this string: $(str)"
Err OutOfBounds -> "That index was out of bounds, sorry!"
Hi @Bryan Maass :)
Can you provide a full self-contained reproduction?
I was not able to reproduce the panic when executing:
app "helloWorld"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.8.1/x8URkvfyi9I0QhmVG98roKBUs_AZRkLFwFJVJ3942YA.tar.br" }
imports [pf.Stdout]
provides [main] to pf
main =
index = 4
resultStr =
when List.get ["a", "b", "c"] index is
Ok str -> "I got this string: $(str)"
Err OutOfBounds -> "That index was out of bounds, sorry!"
Stdout.line resultStr
It also worked with index 0
Thanks for checking it with me. Oh, you know, I'm not sure I had index bound in that example!
It totally works when I don't reference an unbound value!
It still should not panic if index is undefined, I get a nice error message if I try that. Can you share the code that caused a panic?
Last updated: Jul 06 2025 at 12:14 UTC