metals icon indicating copy to clipboard operation
metals copied to clipboard

Debug Watch is broken

Open asarkar opened this issue 2 years ago • 4 comments

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

asarkar avatar Jan 05 '24 14:01 asarkar

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?

debug

tgodzik avatar Jan 05 '24 15:01 tgodzik

https://github.com/scalameta/metals/assets/1302775/5fa60ea7-4b29-4366-8a53-cd4805c8dd8f

https://github.com/asarkar/99-scala

asarkar avatar Jan 06 '24 00:01 asarkar

@tgodzik Is there anything else you need from me?

asarkar avatar Jan 08 '24 00:01 asarkar

We can reproduce, thanks!

tgodzik avatar Jan 08 '24 11:01 tgodzik

Looks like the upstream issue has been fixed, is there anything you need to do on your end?

asarkar avatar Aug 17 '24 20:08 asarkar

Looks to be working in the latest metals, thanks for reminding me! Are you still having any issues?

tgodzik avatar Aug 19 '24 08:08 tgodzik