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

Stream created with fromIterator looping infinitely when evaluated in 3.10.x #3415

Closed
JMdoubleU opened this issue Mar 27, 2024 · 3 comments · Fixed by #3416
Closed

Stream created with fromIterator looping infinitely when evaluated in 3.10.x #3415

JMdoubleU opened this issue Mar 27, 2024 · 3 comments · Fixed by #3416
Labels

Comments

@JMdoubleU
Copy link

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

@JMdoubleU JMdoubleU added the bug label Mar 27, 2024
@mpilquist
Copy link
Member

Maybe related? #3392

@mpilquist
Copy link
Member

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
Copy link
Member

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)

mpilquist added a commit that referenced this issue Mar 28, 2024
Fix #3415 - fromIterator looping infinitely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants