-
-
Notifications
You must be signed in to change notification settings - Fork 418
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 for infinite Ranges #4127
Fix for infinite Ranges #4127
Conversation
Can you include a test to prevent regression in the future? I assume that it is possible to write such a test. |
Hi @stefandd, The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do. Release notes are added by creating a uniquely named file in the The basic format of the release notes (using markdown) should be:
Thanks. |
The title for this PR will be in the CHANGELOG and as such should have a human meaningful title that is descriptive unto itself. @stefandd do you have suggestions for such a title/changelog entry? |
As for the title: the fix addresses the cases of infinite Ranges in which NaN was used for the step. The problem is due to the lack of a sign of NaN (unlike +Inf or -Inf) and the dependence of the has_next() function on the `step` parameter being either > 0 or < 0-- which NaN can't be.
Therefore, I'd say "Fix for Range with NaN step parameters" or something similar would get pretty close.
|
I extended the _assert_infinite() function in packages/collections/_test.pony to now test for both the first AND the second call to .next() being valid in case of infinite Ranges. So far, tests for .next() calls were badly missing for infinite Ranges (see number of failed tests below)! I test for the second .next() to be valid since firstly, one could infer from 2 to infinity :-), but secondly and more importantly because a side effect of the
With the fix, all tests pass! |
I'm not sure why the "arm64 Apple Darwin" job failed, so I've rerun the CI job. |
The `has_next()` function in `Range` relies entirely on the variable `_forward` to decide whether or not another iteration exists. However, `forward` is too narrowly defined to properly cover some or some `_infinite == true` cases. Currently some cases of `step` being 0 or NaN depending on `min > or < max` were broken (ie. not infinite)
The extens the _assert_infinite() function in packages/collections/_test.pony to detect bugs in infinite Ranges
In addition to test the first .next() to not fail, a value assertion for the expected result this call (min) was added
@jemc I am not sure about the GitHub and PonyC etiquette: was it proper to request the review by all 3 reviewers after you approved? I saw 3 assigned reviewers and thought that this wass the right thing to do. |
@stefandd It's fine. I've been a bit busy so I won't probably get the time to properly review this until Sunday. |
The extens the _assert_infinite() function in packages/collections/_test.pony to detect bugs in infinite Ranges
The extens the _assert_infinite() function in packages/collections/_test.pony to detect bugs in infinite Ranges
The
has_next()
function inRange
relies entirely on the variable_forward
to decide whether or not another iteration exists. However,_forward
is too narrowly defined to properly cover some or some_infinite == true
cases. Currently some cases ofstep
being 0 or NaN depending onmin > or < max
were broken (ie. not infinite)