Hello. I'm wondering if anyone has tips for debugging panics. I'd like to be able to at least attempt to debug them myself before posting errors/code. I tried enabling the backtrace, but didn't see anything that would be helpful (for me personally). Otherwise, I'd only thought to look at the point where the panic was thrown, but I'm not familiar enough with the code for that to get me very far yet. Any tips are appreciated!
This is when writing roc code? Just some change ends up leading to the compiler panicking?
Yea, when writing Roc code.
Ok. Cool. First thing to always try is roc check
. It will often find the issue for you.
Thanks. I did try that, and unfortunately didn't turn up any issues.
Quickly things get harder if roc check
fails to tell you the issue.
For me, I have a rough idea of where different errors come from. Some panics, it is useful to look at source, but many, it is too deep to help much. I am not sure I have much better advice than look at diffs and try comment out code. If you need types to match when commenting out code, crash
can be helpful to fill in a branch. The hope is that if roc check
passes, compilation will always succeed, but that sadly is not reality currently. Definitely feel free to keep asking here. Also, filing these bugs is extremely useful, especially if you can minimize them. That is how we will slowly work to fix them.
Ok, thanks. It seems to be happening during code gen too, so makes debugging a little trickier. I haven't had much luck isolating with my code as is, so maybe I'll try producing a more minimal example.
Interesting, adding a type annotation to a function stops the panic. I'll try to strip my example down a little more then open an issue.
I opened the issue here: https://github.com/roc-lang/roc/issues/5344
David Smith has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC