-
Notifications
You must be signed in to change notification settings - Fork 165
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
Fixed bugs in RestrictedPerm
with second argument a range.
#4178
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
Just to say, we could also change RestrictedPerm to just reject inputs which contain non-positive integers -- while it looked to me like the intention was to support it, I'm now investigating and it looks like it might be more sensible to reject it. |
cfb5160
to
0c883c1
Compare
1) If the list contained negative numbers, () was always returned 2) Ranges with steps which were not = 1 were mishandled
0c883c1
to
843b09d
Compare
Code now reformatted and simplified somewhere, I now (correctly) just reject negative inputs. Added (possibly too many) tests, to make sure all the various boundary conditions are hit properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great.
RestrictedPerm
with second argument a range.
Backported to stable-4.11 via PR #4262 |
The code in RestrictedPerm for handling ranges had a few bugs (I found issue (2) in some code I was working on, when I went to investigate I noticed issue (1))
Rather than try to fix the old code, which was both buggy and confusing, I just wrote a (hopefully) much simpler loop, which I believe will be just as efficient (as the only one wasn't trying to do "clever skipping" anyway.