Skip to content

Incorrect behavior with take on empty vector iterator #12479

@adampauls

Description

@adampauls

reproduction steps

using Scala 2.13.7

object Test {
  def main(args: Array[String]): Unit = {
    val xx: Vector[Int] = Vector.empty[Int]
    val rev = xx.reverseIterator
    assert(rev.isEmpty)
    val afterTake = rev.take(1)
    assert(afterTake.isEmpty) // fails but shouldn't
  }
}

problem

The second assert failes and shouldn't. Attempting to use afterTake will crash with an IndexOutOfBoundException.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions