Aladdin - Scala Bugtracking
[#1074] project: api priority: medium category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2007-05-01 12:38:40.0
subject [contrib #445] HashSet.filter is broken
code
object SetBug {
  def main(args : Array[String]) : Unit = {
    var words = "a" :: "b" :: "cd" :: "de" :: "fg" :: "ef" ::
               "gh" :: "jk" :: "hj" :: "kl" :: "lm" :: "mn" :: Nil
    val q0:Set[String] =
      new scala.collection.immutable.HashSet[String]() ++ words
    Console.println("q0 = " + q0)
    Console.println("q1 = " + q0.filter(w => false))
    Console.println("q2 = " + q0.filter(w => false).filter(w => false))
 }
}
what happened
Here's the output:

q0 = HashSet$$anon$0(kl, jk, cd, fg, a, ef, gh, de, hj, b, lm, mn)
q1 = HashSet$$anon$0(fg, gh)
q2 = HashSet$$anon$0()
what expected I would expect that filter with a predicate which always returns false will always return the empty set. Somehow, it doesn't.
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-05-01 12:39:17.0
contribution #445
Martin  edited on  2007-05-10 19:21:50.0