scala / bug

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

ListBuffer.patchInPlace does not update last0 field, leaving the buffer in a corrupted state #12796

Closed noresttherein closed 1 year ago

noresttherein commented 1 year ago

Reproduction steps

Scala version: 2.13.10

    import collection.mutable.ListBuffer
    val buffer = ListBuffer(1)
    val patch = Seq(2)
    buffer.patchInPlace(1, patch, 2)
    println(buffer.last)

Problem

Prints 1

noresttherein commented 1 year ago

BTW, I found this through a static analysis of my improvement to ListBuffer, which I hope to make public on the days, and which fixes it in one sweep, so depending on how fast you need this one to be merged, you may not need to jump onto it this very moment.

SethTisue commented 1 year ago

@scala/collections

NthPortal commented 1 year ago

uh oh. I feel like I caused this