Stream: beginners

Topic: wrong panic messages


view this post on Zulip Brendan Hansknecht (Dec 09 2023 at 20:25):

Just curious has anyone else seen roc give the wrong panic message?

Recently I saw a case of "multiplication overflow", but it came from an addition.

view this post on Zulip Richard Feldman (Dec 09 2023 at 20:26):

I've specifically seen reports of that one

view this post on Zulip Richard Feldman (Dec 09 2023 at 20:27):

of it saying multiplication overflow where it should have said something else (I heard about it in the case of subtraction instead of addition)

view this post on Zulip Richard Feldman (Dec 09 2023 at 20:30):

only kinda related, but I think we could make that error message a lot more helpful, especially for people not used to different number types - e.g. U8 multiplication overflowed. U8s range from 0 to 255, and this multiplication resulted in a number outside those bounds. Converting to a larger number size (e.g. by calling Num.toU16 on both numbers) before multiplying would increase these bounds.

view this post on Zulip Ryan Bates (Dec 09 2023 at 20:55):

I would appreciate a more clarified error message. You could also suggest using signed int version if they attempt to go below zero.

view this post on Zulip Brendan Hansknecht (Dec 09 2023 at 21:04):

Could also mention the saturating or wrapping versions of the functions

view this post on Zulip Richard Feldman (Dec 09 2023 at 21:05):

maybe just link to some docs on how to handle overflow

view this post on Zulip Declan Joseph Maguire (Dec 10 2023 at 02:10):

Wait, does Roc have the wrapping and saturating version of arithmetic infix operators, like Zig does? Or just the regular addWrap et. al. functions?

view this post on Zulip Brendan Hansknecht (Dec 10 2023 at 02:10):

functions only

view this post on Zulip Declan Joseph Maguire (Dec 10 2023 at 02:12):

Damn, those infix versions are super nice in Zig. They basically solve all the ergonomic problems of always crashing on overflow, if you're trying to write something very numerical.


Last updated: Jul 26 2025 at 12:14 UTC