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

Range#{last, lastElement, terminalElement, ...} are completely undocumented and most likely broken #6747

Closed
scabug opened this issue Dec 1, 2012 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Dec 1, 2012

scala>  (0 to Int.MaxValue).last
res34: Int = -2
scala>  (0 to Int.MaxValue).lastElement
res35: Int = -2
scala>  (0 to Int.MaxValue).terminalElement
res36: Int = -1
scala>  (0 to Int.MaxValue).numRangeElements
res37: Int = -1

This mess is caused by no documentation (especially not about how possibly invalid inputs are treated), unhandled numeric overflows and made worse by making these things public.

The only reason why we don't check our inputs immediately is to allow by to work. That means every other method needs to enforce our invariants.

I assume the methods above are not the only ones which don't do this.

@scabug
Copy link
Author

scabug commented Dec 1, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6747?orig=1
Reporter: @soc

@scabug
Copy link
Author

scabug commented Jun 9, 2013

@soc said:
scala/scala#2645

@scabug scabug closed this as completed Nov 21, 2013
@scabug scabug added this to the 2.11.0-M4 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants