Debug Watch is broken
Describe the bug
Consider this trivial Scala code that returns the last element of a list.
object P01:
def last[A](l: List[A]): A = l match
case lst :: Nil => lst
case _ :: tail => last(tail)
case Nil => throw new NoSuchElementException("last of empty list")
When debugging is started from a MUnit test and a breakpoint added on the first case statement, the execution pauses. Adding an expression l.size in the watch panel fails with the following exception. In fact, no expression works in the watch panel for any code whatsoever. Sometimes it shows another error message, but the exception is always some sort of array out of bounds.
Cannot evaluate because of java.lang.NegativeArraySizeException: -2.
Expected behavior
Watch panel should be able to evaluate expressions.
Operating system
macOS
Editor/Extension
VS Code
Version of Metals
v1.27.0
Extra context or search terms
VSCode: Version: 1.85.1 OS: Darwin arm64 23.2.0
Scala (Metals) extension: v1.27.0
Scala: v3.3.1. MUnit: 1.0.0-M10
JDK: openjdk 17.0.9
Thanks for reporting! It seems to work in my case. Would you be able to post a full reproduction of the project it's not working for?
https://github.com/scalameta/metals/assets/1302775/5fa60ea7-4b29-4366-8a53-cd4805c8dd8f
https://github.com/asarkar/99-scala
@tgodzik Is there anything else you need from me?
We can reproduce, thanks!
Looks like the upstream issue has been fixed, is there anything you need to do on your end?
Looks to be working in the latest metals, thanks for reminding me! Are you still having any issues?