Stream: beginners

Topic: ✔ Tips for debugging panics


view this post on Zulip David Smith (Apr 28 2023 at 21:13):

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!

view this post on Zulip Brendan Hansknecht (Apr 28 2023 at 21:14):

This is when writing roc code? Just some change ends up leading to the compiler panicking?

view this post on Zulip David Smith (Apr 28 2023 at 21:16):

Yea, when writing Roc code.

view this post on Zulip Brendan Hansknecht (Apr 28 2023 at 21:18):

Ok. Cool. First thing to always try is roc check. It will often find the issue for you.

view this post on Zulip David Smith (Apr 28 2023 at 21:19):

Thanks. I did try that, and unfortunately didn't turn up any issues.

view this post on Zulip Brendan Hansknecht (Apr 28 2023 at 21:21):

Quickly things get harder if roc check fails to tell you the issue.

view this post on Zulip Brendan Hansknecht (Apr 28 2023 at 21:33):

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.

view this post on Zulip David Smith (Apr 28 2023 at 21:35):

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.

view this post on Zulip David Smith (Apr 29 2023 at 03:12):

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.

view this post on Zulip David Smith (Apr 29 2023 at 14:00):

I opened the issue here: https://github.com/roc-lang/roc/issues/5344

view this post on Zulip Notification Bot (Apr 29 2023 at 14:01):

David Smith has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC