scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

immutable.BitSet::diff() returns wrong results #12753

Closed binuwada closed 1 year ago

binuwada commented 1 year ago

Reproduction steps

Scala versions: 2.13.10, 3.2.2

The diff() method should return the difference of two sets, but it returns a wrong (empty) result in some cases, e.g.

Welcome to Scala 3.2.2 (11.0.18, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> import scala.collection.mutable.BitSet

scala> val expected = BitSet(63, 128) diff BitSet(128)
val expected: scala.collection.mutable.BitSet = BitSet(63)

scala> import scala.collection.immutable.BitSet

scala> val wrong = BitSet(63, 128) diff BitSet(128)
val wrong: scala.collection.immutable.BitSet = BitSet()

Problem

wrong should not be empty but like expected. The behavior under Scala 2.13.10 is identically wrong, as expected, since it is based on the same sources.

lrytz commented 1 year ago

Thanks! This was recently fixed and will be released very soon with 2.13.11: https://github.com/scala/scala/pull/10238