scala / bug

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

IndexedSeqOps.head = apply(0) throws IndexOutOfBoundsException, not NoSuchElementException #12782

Closed noresttherein closed 1 year ago

noresttherein commented 1 year ago

Reproduction steps

Scala version: 2.13.10

Problem

Implementing IndexedSeq and not overriding head leads to an IOOBE being thrown, contrary to NSEE mentioned in the specification. This does not affect Vector, as it overrides head. The same goes for last.

SethTisue commented 1 year ago

@scala/collections

OndrejSpanel commented 1 year ago

Is it possible to fix this without breaking binary compatibility?

som-snytt commented 1 year ago

apply has the annotation, and this is the first time I've noticed how it is rendered: image

head has only Scaladoc.