Reproduction steps
Standard library bug. Example in Scala 3 REPL:
scala> val lm = collection.mutable.LongMap.empty[String]
val lm: scala.collection.mutable.LongMap[String] = LongMap()
scala> val minA = lm.put(Long.MinValue, "eel")
val minA: Option[String] = None
scala> val minB = lm.put(Long.MinValue, "cod")
val minB: Option[String] = None
Problem
An apparently LLM-generated PR noticed that line 294 in collection.mutable.LongMap contains a vacuous test:
val ans = if ((extraKeys&2) == 1) Some(minValue.asInstanceOf[V]) else None
Because of this, when LongMap has a pre-existing Long.MinValue key, indicated by bit 0x2 set in extraKeys, it incorrectly finds nothing and returns None. The map remains correct; the only problem is that the stored value is lost rather than being returned by put as its contract requires.
The LLM correctly guessed that it was meant to be == 2, but did not test the fix or submit a test. I also do not have time right now to do this, but I understand the context and that there is genuinely incorrect behavior.
Reproduction steps
Standard library bug. Example in Scala 3 REPL:
Problem
An apparently LLM-generated PR noticed that line 294 in
collection.mutable.LongMapcontains a vacuous test:Because of this, when
LongMaphas a pre-existingLong.MinValuekey, indicated by bit 0x2 set inextraKeys, it incorrectly finds nothing and returnsNone. The map remains correct; the only problem is that the stored value is lost rather than being returned byputas its contract requires.The LLM correctly guessed that it was meant to be
== 2, but did not test the fix or submit a test. I also do not have time right now to do this, but I understand the context and that there is genuinely incorrect behavior.