Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
NumericRange.max returns unexpected value on empty ranges #10060
scala> Range.Long.inclusive(111, 999, -1).max res28: Long = 111
More examples here https://gist.github.com/tabdulradi/b3ff116032f2eb16aedf077d8e5f8427
Imported From: https://issues.scala-lang.org/browse/SI-10060?orig=1
and porting it to NumericRange:
Looking at https://github.com/scala/scala/blob/v2.12.0/src/library/scala/collection/immutable/Range.scala#L78-L82, it seems the intention is that range creation should create an empty range.
But looking at https://github.com/scala/scala/blob/v2.12.0/src/library/scala/collection/immutable/NumericRange.scala#L49-L53 (which seems relevant for Range.Long stuff), and at NumericRange.count, it's not obvious that's actually the case.
Since you wrote on Gitter you'd like to work on this: it'd be great, if you can, to also add some testcases at least for this behavior (possibly applying to both sort of ranges?). But a patch would already help.