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
valrange=BigInt("0") until BigInt("1000000000000")
println(range.take(10).toList)
Output
java.lang.ExceptionInInitializerError
at Main$.<clinit>(main.scala:8)
at Main.main(main.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at sbt.Run.invokeMain(Run.scala:143)
at sbt.Run.execute$1(Run.scala:93)
at sbt.Run.$anonfun$runWithLoader$5(Run.scala:120)
at sbt.Run$.executeSuccess(Run.scala:186)
at sbt.Run.runWithLoader(Run.scala:120)
at sbt.Run.run(Run.scala:127)
at com.olegych.scastie.sbtscastie.SbtScastiePlugin$$anon$1.$anonfun$run$1(SbtScastiePlugin.scala:38)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:17)
at sbt.ScastieTrapExit$App.run(ScastieTrapExit.scala:258)
at java.base/java.lang.Thread.run(Thread.java:831)
Causedby: 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)
at Playground$.<clinit>(main.scala:4)
... 17 more
https://scala-lang.org/api/3.x/scala/collection/immutable/Range.html
Documentation says an exception will be thrown when a collection is created with too many elements, or asked to index beyond Int.MaxValue will thrown an exception. However, shown code example arguably does not access elements beyond Int.MaxValue?
Scala2 bug repository suggests an IllegalArgumentException should be thrown if the initialized range is too large scala/bug#4308scala/bug#4042
The text was updated successfully, but these errors were encountered:
Compiler version
3.2.0
Minimized code
Output
See also https://scastie.scala-lang.org/BalmungSan/J36g8PSjTuy0i284aMMw1A/1
Expectation
https://scala-lang.org/api/3.x/scala/collection/immutable/Range.html
Documentation says an exception will be thrown when a collection is created with too many elements, or asked to index beyond Int.MaxValue will thrown an exception. However, shown code example arguably does not access elements beyond Int.MaxValue?
Scala2 bug repository suggests an IllegalArgumentException should be thrown if the initialized range is too large scala/bug#4308 scala/bug#4042
The text was updated successfully, but these errors were encountered: