Example Suggestion: Safe Arithmetic
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 46
- Forks
- 19
- Avg merge
- 13h 38m
- Merged PRs (30d)
- 19
Description
Just going through the examples, thank you so much for the effort you are making here.
I am reading through the Arithmetic example and I think there's the obvious edge case about dividing by zero.
According to roc's current div documentation:
Division by zero is undefined in mathematics. As such, you should make sure never to pass zero as the denomaintor to this function! Calling div on a Dec denominator of zero will cause a panic.
Possible solutions:
-
Adjust the example text to state that if the second argument is
0, we can skip theinteger quotientoperation; -
Adjust the example text to state that zero is not a valid input for the second argument, and add an explicit check on the
readArgsfunction for this case -
Adjust the example text to state that an input of 0 on the second argument is allowed to crash with a
Floating point exception
My preference would be between solution 1 or 2, or a smarter one :)
Let me know your thoughts and once again, thank you for this amazing effort!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Arithmetic example and its readArgs function, then read the Roc div documentation linked in the issue to confirm the zero-denominator behavior. Decide whether the example should skip integer quotient, reject zero input, or document the crash; done means the example no longer presents an unsafe zero-denominator path without explanation.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100