2017-05-09 48 views
1

花了一些時間對一些代碼進行故障排除,發現了「to」的bug。我錯過了什麼?Scala mutable.TreeMap「to」bug in 2.12.1?

Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_121). 
Type in expressions for evaluation. Or try :help. 

scala> val is = collection.mutable.TreeMap[Int, Int]() 
is: scala.collection.mutable.TreeMap[Int,Int] = TreeMap() 
scala> is += 0 -> 9 += 70 -> 100 
res0: is.type = TreeMap(0 -> 9, 70 -> 100) 
scala> is.from(30) 
res1: scala.collection.mutable.TreeMap[Int,Int] = TreeMap(70 -> 100) 
scala> is.to(30) 
res2: scala.collection.mutable.TreeMap[Int,Int] = TreeMap() // !!!!! 

scala> val is2 = collection.immutable.TreeMap[Int, Int]() 
is2: scala.collection.immutable.TreeMap[Int,Int] = Map() 
scala> val is3 = is2 + (0 -> 9) + (70 -> 100) 
is3: scala.collection.immutable.TreeMap[Int,Int] = Map(0 -> 9, 70 -> 100) 
scala> is3.from(30) 
res3: scala.collection.immutable.TreeMap[Int,Int] = Map(70 -> 100) 
scala> is3.to(30) 
**res4: scala.collection.immutable.TreeMap[Int,Int] = Map(0 -> 9)** 

回答

5

這似乎是一個2.12.1的錯誤,在2.12.2更正。這可能與this有關。

+0

謝謝,似乎是這個,在Jira問題中的最後一個例子正是我所得到的。 – Valentin

+0

不客氣!請將答案標記爲已接受,如果它滿足你,以便其他人可以找到它。 –