Hi there. Love the progress on the new compiler :ok:
I decided to check it on some old code. After a couple of modifications to modernize it, I reached the following snippet (reduced from a larger file):
module [last]
last = |l|
match l {
[] -> Err(EmptyList)
[.., e] -> Ok(e)
}
I'm wondering if the syntax is correct but I managed to craft an example that crashes the compiler :stuck_out_tongue_closed_eyes:
[1] 89899 segmentation fault ./zig-out/bin/roc check main.roc
Match uses =>
now.
Shouldn't segfault though :thinking:
Still segfaults with =>
but what I was looking for was the right syntax. Thank you
In fact I could have just looked through the new snapshots (which are great btw). But at least the segfault gets reported
Hmmm don't know if it might help with debugging, but if I invert the order of the branches it works:
module [last]
last = |l|
match l {
[.., e] => Ok(e)
[] => Err(EmptyList)
}
This works too:
module [last]
last = |l|
match l {
_ => Err(EmptyList)
[.., e] => Ok(e)
}
Seems to happen when an empty list is the first branch.
That's a cool bug.
thanks for reporting this! I'm working on a fix.
fix: https://github.com/roc-lang/roc/pull/7986
Actually it doesn't seem to be fixed :thinking:
(leaving the example here again)
module [last]
last = |l|
match l {
[] => Err(EmptyList)
[.., e] => Ok(e)
}
It looks related to nested patterns specifically
It's fine with either just a lambda or just a match, but both tother and we are re-using the same scratch for patterns (my current theory)
This is why we need to clean up all the low hanging fuzzer crashes. Then it can reach more meaningful failures like this
Apparently our segfault is in the type-checker ... specifically with empty lists
Ok, I've got a fix... I'll push it up soon.
https://github.com/roc-lang/roc/pull/7988
Last updated: Jul 26 2025 at 12:14 UTC