Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix `%` not to crash when divisor is 0 #866

Merged
merged 2 commits into from Oct 28, 2019
Merged

Fix `%` not to crash when divisor is 0 #866

merged 2 commits into from Oct 28, 2019

Conversation

@0x005c
Copy link
Contributor

0x005c commented Oct 27, 2019

Executing % 1 0 on elvish cause runtime error and elvish crash.
As one solution, I implemented mod function which returns ErrArgs if divisor is 0.

@@ -139,6 +139,13 @@ func divide(fm *Frame, prod float64, nums ...float64) {
out <- vals.FromGo(prod)
}

func mod(fm *Frame, a, b int) (int, error) {

This comment has been minimized.

Copy link
@xiaq

xiaq Oct 27, 2019

Member

The *Frame argument here is superfluous; remove it.

@0x005c
Copy link
Contributor Author

0x005c commented Oct 28, 2019

Thank you for reviewing! I fixed it now :D

@xiaq xiaq merged commit 411b9ab into elves:master Oct 28, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@0x005c 0x005c deleted the 0x005c:fix-mod0-crash branch Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.