Stream: beginners

Topic: Num.div bug? (4047)


view this post on Zulip Bryce Miller (Sep 16 2022 at 01:48):

I'm running into an issue where Num.div sometimes crashes the compiler if passed numbers with inferred types of Num *

1 / 4 returns a float.
1 / 200 crashes the compiler.

Performing the same 1/200 operation on two numbers that have been manually annotated as Num * produces a type error.

Not sure what the intended behavior is here.

view this post on Zulip Bryce Miller (Sep 16 2022 at 01:49):

I'm working on submitting an issue, but first wanted to make sure this wasn't a known issue and that I'm not misunderstanding how things are supposed to work

view this post on Zulip Ayaz Hafiz (Sep 16 2022 at 01:52):

I don’t think this is a known issue. Definitely sounds like a serious problem, thanks for filing a report!

view this post on Zulip Bryce Miller (Sep 16 2022 at 01:54):

e.g.

num1 : Num *
num1 = 1
num2 : Num *
num2 = 200

num1 / num2

produces 0.005 : Float a
(Should that be a Float *?)

view this post on Zulip Bryce Miller (Sep 16 2022 at 01:55):

I'll finish up the report and update the topic with the issue #

view this post on Zulip Bryce Miller (Sep 16 2022 at 02:22):

https://github.com/roc-lang/roc/issues/4047


Last updated: Jul 06 2025 at 12:14 UTC