-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[REVISIT NEEDS SPEC] Respect bounds in indexOfSlice [ci: last-only] #10385
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
Conversation
TIL there is a scalacheck.
Edit: not |
c9d2b46
to
109a7ee
Compare
As sjrd pointed out on the ticket, it's desirable for The fix is for the case where source seq and slice do not both have known lengths. If the source seq has a known length, we can distinguish Otherwise, we count the prefix elements up to |
d704e60
to
d82b613
Compare
6365ca7
to
fcb49ab
Compare
I dozed briefly with my head on the keyboard and had a dream in which The added commit "returns them", as in returning product to Costco. Also rebased, as it incurs only one CI run. I will leave the PR unsquashed for a short period for review purposes. |
fcb49ab
to
fc4739f
Compare
I feel like we need to agree on, and spec, out-of-bounds handing before fixing individual issues. scala/bug#12795 (comment) |
The sjrd justification is that it returns a number
I suspect that only operations requiring an existing element ("the index of an existing element") should throw, paradigmatically, |
fc4739f
to
721fc2f
Compare
Fixes scala/bug#12780
Fixes scala/bug#12781
The non-trivial tweak is L51 of the test:
from
can'tcan be after the last elements,evento match an empty sequence.The "generic" slow path, with unknown size, matches
nothing[Ed empty] once the sequence is empty.