Hello, I've used many different languages and I started to learn Roc a few days ago. It reminds me a little of F# and OCaml, except the "fast, friendly, functional" tagline really resonates with me.
To get more comfortable with Roc, I'm attempting to solve problems from Everybody Codes (it's like AoC). I ran into an issue with year 2025 problem 1.
test_names = "Vyrdax,Drakzyph,Fyrryn,Elarzris"
test_dirs = "R3,L2,R3,L1"
main! = |_args| {
names = test_names.split_on(",")
dirs = test_dirs.split_on(",")
var $name_index = 0.I64
for dir in dirs {
right = dir.starts_with("R")
dist = I64.from_str(dir.drop_prefix("R").drop_prefix("L"))
dbg right
dbg dist
match dist {
Ok(d) => {
sd = if right d else -d
$name_index = $name_index + sd
if $name_index < 0 {
$name_index = 0
}
# Uncomment the code below to get a segfault
#if $name_index >= names.len() {
# $name_index = names.len() - 1
#}
}
Err(_e) => { crash "bad" }
}
}
dbg $name_index
Ok({})
}
If I uncomment the commented code block, I get a segfault. I don't know if I'm using Roc incorrectly or if this is a bug I should report. If it is a bug, should I report it on github?
Thanks!
Welcome @cerk :)
This is indeed a bug, I will put it up on github.
Last updated: Aug 12 2026 at 12:35 UTC