New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ListBuffer's insert, insertAll, update and updated accept negative positions #6632
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6632?orig=1 |
@soc said: |
@JamesIry said: |
@adriaanm said: |
@gkossakowski said: |
@Ichoran said: |
@SethTisue said: |
@soc said: Imho a good way to start would be to survey whether there is some kind of implicit consensus in the other implementations on how to behave and it's just this one which behaves differently, or whether implementations' behavior in error cases is all over the place. |
@soc said: scala> import collection.mutable.{ArrayBuffer => ListBuffer}
import collection.mutable.{ArrayBuffer=>ListBuffer}
scala> val lb = ListBuffer('a, 'b, 'c, 'd, 'e)
lb: scala.collection.mutable.ArrayBuffer[Symbol] = ArrayBuffer('a, 'b, 'c, 'd, 'e)
scala> lb.updated(-4, 'd)
res7: scala.collection.mutable.ArrayBuffer[Symbol] = ArrayBuffer('d, 'b, 'c, 'd, 'e)
scala> lb.updated(12, 'd)
java.lang.UnsupportedOperationException: empty.tail
at scala.collection.TraversableLike$class.tail(TraversableLike.scala:449)
at scala.collection.mutable.IndexedSeqLike$$anon$1.scala$collection$IndexedSeqOptimized$$super$tail(IndexedSeqLike.scala:52)
at scala.collection.IndexedSeqOptimized$class.tail(IndexedSeqOptimized.scala:129)
at scala.collection.mutable.IndexedSeqLike$$anon$1.tail(IndexedSeqLike.scala:52)
at scala.collection.SeqLike$class.updated(SeqLike.scala:516)
at scala.collection.AbstractSeq.updated(Seq.scala:41)
... 32 elided |
@adriaanm said: |
@Ichoran said: |
None of the following operations should succeed:
The documentation even specifies:
The text was updated successfully, but these errors were encountered: