-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
[Ruby] Fix RepeatedField#last, #first inconsistencies #9722
Conversation
This looks good. I will merge it after our test suite finishes |
Looks like this is failing tests:
|
Looks like the failure is in jruby. Jason? |
It appears that the fix for this issue has uncovered a separate bug in the JRuby implementation of the @lucthev - if you're comfortable working in Java, you can fix both issues in the same PR. If not, please open a separate ticket for the JRuby-specific issue and I can work up a patch. |
rerunning test suite. Will come back tomorrow to see how it went |
Thanks for the reviews! I had a stab at fixing the issue in In the meantime, I've worked around that in this PR by not using a negative index. |
RepeatedField#last(n)
has an off-by-one error resulting in one more element being returned than requested.While I was at it, I also fixed the following inconsistencies with
Array
:last(n)
where n > size should return all elements; the current implementation wraps around such that e.g.last(size + 2) == last(2)
last(n)
where n < 0 should raise anArgumentError