Skip to content

Nil.par.reduceLeft should throw UnsupportedOperationException, not NoSuchElementException #137

@retronym

Description

@retronym
% scala --scala-version 2.13.3 -Corg.scala-lang.modules::scala-parallel-collections:1.0.0-RC1
Welcome to Scala 2.13.3 (OpenJDK 64-Bit Server VM, Java 14.0.1).
Type in expressions for evaluation. Or try :help.

scala> List.empty[String].reduce(_ + _)
java.lang.UnsupportedOperationException: empty.reduceLeft
  at scala.collection.IterableOnceOps.reduceLeft(IterableOnce.scala:723)
  at scala.collection.IterableOnceOps.reduceLeft$(IterableOnce.scala:720)
  at scala.collection.AbstractIterable.reduceLeft(Iterable.scala:920)
  at scala.collection.IterableOnceOps.reduce(IterableOnce.scala:692)
  at scala.collection.IterableOnceOps.reduce$(IterableOnce.scala:692)
  at scala.collection.AbstractIterable.reduce(Iterable.scala:920)
  ... 32 elided

scala> import scala.collection.parallel.CollectionConverters._
import scala.collection.parallel.CollectionConverters._

scala> List.empty[String].par.reduce(_ + _)
java.util.NoSuchElementException: None.get
  at scala.None$.get(Option.scala:627)
  at scala.None$.get(Option.scala:626)
  at scala.collection.parallel.ParIterableLike.reduce(ParIterableLike.scala:361)
  at scala.collection.parallel.ParIterableLike.reduce$(ParIterableLike.scala:360)
  at scala.collection.parallel.immutable.ParVector.reduce(ParVector.scala:40)
  ... 32 elided

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions