You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a wide NumericRange, say BigInt(0) until (BigInt(Int.MaxValue) + 1000), if you try to take some amount from the range, or drop some from it, it causes IllegalArgumentException. question on stackoverflow
Scala version: 3.x, 2.13.x
scala>valrange=BigInt(0) until (BigInt(Int.MaxValue) +1000)
valrange: scala.collection.immutable.NumericRange.Exclusive[scala.math.BigInt] =NumericRange0 until 2147484647
scala> range.take(2)
java.lang.IllegalArgumentException:More than Int.MaxValue elements.
at scala.collection.immutable.NumericRange$.check$1(NumericRange.scala:324)
at scala.collection.immutable.NumericRange$.count(NumericRange.scala:334)
at scala.collection.immutable.NumericRange.length$lzycompute(NumericRange.scala:75)
at scala.collection.immutable.NumericRange.length(NumericRange.scala:75)
at scala.collection.immutable.NumericRange.take(NumericRange.scala:143)
... 32 elided
scala> range.drop(Int.MaxValue)
java.lang.IllegalArgumentException:More than Int.MaxValue elements.
at scala.collection.immutable.NumericRange$.check$1(NumericRange.scala:324)
at scala.collection.immutable.NumericRange$.count(NumericRange.scala:334)
at scala.collection.immutable.NumericRange.length$lzycompute(NumericRange.scala:75)
at scala.collection.immutable.NumericRange.length(NumericRange.scala:75)
at scala.collection.immutable.NumericRange.drop(NumericRange.scala:149)
... 32 elided
Problem
The problem is the unexpected behavior of the range. It's the fact that you are able to create a wide range, but you can not take a small piece of it.
The text was updated successfully, but these errors were encountered:
AminMal
added a commit
to AminMal/scala
that referenced
this issue
Dec 30, 2022
Reproduction steps
Given a wide
NumericRange
, sayBigInt(0) until (BigInt(Int.MaxValue) + 1000)
, if you try to take some amount from the range, or drop some from it, it causesIllegalArgumentException
. question on stackoverflowScala version: 3.x, 2.13.x
Problem
The problem is the unexpected behavior of the range. It's the fact that you are able to create a wide range, but you can not take a small piece of it.
The text was updated successfully, but these errors were encountered: