`Stream` created with `fromIterator` looping infinitely when evaluated in 3.10.x
JMdoubleU opened this issue · 3 comments
JMdoubleU commented
3.10.1: https://scastie.scala-lang.org/MPJYpbXjTvifxeJztJf2fg
3.10.0: https://scastie.scala-lang.org/HeqY0ewsQ9acwk4PcfS2Rw
3.9.4 (expected behavior): https://scastie.scala-lang.org/qjLFGGvHQPKRe8GDrpaDKw
mpilquist commented
Yep, that's the cause:
scala> val i = Vector(1, 2).iterator
val i: Iterator[Int] = <iterator>
scala> i.take(5).toVector
val res0: Vector[Int] = Vector(1, 2)
scala> i.take(5).toVector
val res1: Vector[Int] = Vector(1, 2)
scala> i.take(5).toVector
val res2: Vector[Int] = Vector(1, 2)
mpilquist commented
Here's a fun one:
scala> val i = Vector(1, 2).iterator; i.take(5).toList; i.take(5).toList
val i: Iterator[Int] = <iterator>
val res0: List[Int] = List(1, 2)
val res1: List[Int] = List()
scala> val i = Vector(1, 2).iterator; i.take(5).toVector; i.take(5).toVector
val i: Iterator[Int] = <iterator>
val res2: Vector[Int] = Vector(1, 2)
val res3: Vector[Int] = Vector(1, 2)