Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug watch throws NoSuchElementException #6761

Closed
asarkar opened this issue Sep 9, 2024 · 10 comments
Closed

Debug watch throws NoSuchElementException #6761

asarkar opened this issue Sep 9, 2024 · 10 comments
Labels
needs more information Use if we need more information for a specific ticket

Comments

@asarkar
Copy link

asarkar commented Sep 9, 2024

Describe the bug

object AtbashCipher:
  private val mapping = ('a' to 'z').toIndexedSeq

  def encode(plain: String): String =
    val cipher = xcode(plain, mapping.size - 1 - _ + 'a')

    cipher.grouped(5).mkString(" ")

  def decode(cipher: String): String =
    xcode(cipher, 'z' - _)

  private def xcode(s: String, f: Char => Int): String =
    val text = for c <- s; x = f(c.toLower); if c.isLetterOrDigit
    yield (if c.isDigit then c else mapping(x))

    text.mkString

When a breakpoint is put on the line yield, and variables c and x added to the watch, the panel throws NoSuchElementException. See screenshot below.

Screenshot 2024-09-08 at 5 50 00 PM

Expected behavior

Watch panel should be able to evaluate expressions.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.3.5

Extra context or search terms

VSCode version 1.93.0
Scala version 3.4.2
JDK Version 21.0.4

@tgodzik
Copy link
Contributor

tgodzik commented Sep 10, 2024

This works for me on the newest snapshot of Metals, so this might have actually been already fix. I will try and release a new version of metals soon.

@tgodzik tgodzik added the needs more information Use if we need more information for a specific ticket label Sep 10, 2024
Copy link

This issue was closed because no new information was added for the last 30 days. If you have any relevant information, feel free to add it and reopen the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2024
@asarkar
Copy link
Author

asarkar commented Oct 11, 2024

What more information is required?

@tgodzik
Copy link
Contributor

tgodzik commented Oct 11, 2024

Ach, I think I forgot to write if you could check the snapshot versions. I was supposed to release a new version, but I keep finding bugs to fix

@tgodzik tgodzik reopened this Oct 11, 2024
@tgodzik tgodzik added investigation needed and removed needs more information Use if we need more information for a specific ticket labels Oct 11, 2024
@asarkar
Copy link
Author

asarkar commented Oct 11, 2024

Thanks for reopening the ticket. I think I’ll wait for a stable version, no rush. Snapshot might fix this problem but introduce another.

@tgodzik
Copy link
Contributor

tgodzik commented Oct 31, 2024

Are you able to reproduce it in 1.4.0 Metals version?

@tgodzik tgodzik added needs more information Use if we need more information for a specific ticket and removed investigation needed labels Oct 31, 2024
@asarkar
Copy link
Author

asarkar commented Nov 1, 2024

I still am able to reproduce it using 1.4.0 Metals and VSCode 1.95.1

@tgodzik
Copy link
Contributor

tgodzik commented Nov 4, 2024

Looks like the reason for it is that first stop is not inside the for, but outside of it. @adpi2 any idea is that expected? Might be limitation.

@adpi2
Copy link
Member

adpi2 commented Nov 4, 2024

Looks like the reason for it is that first stop is not inside the for, but outside of it. @adpi2 any idea is that expected? Might be limitation.

Yes the issue is the compiler declares a debug line on the instantiation of the lambda.

In this example:

xs.map { x =>
  x + 1
}

The compiler creates 3 debug lines: one on map, one on x => x + 1 and another one on x + 1. When you stop on x => x + 1, you cannot evaluate x, because it does not exist yet, hence the NoSuchElementException.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 4, 2024

Looks like this is expected and work as intended. Thanks @adpi2 for adding the additional info.

@tgodzik tgodzik closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more information Use if we need more information for a specific ticket
Projects
None yet
Development

No branches or pull requests

3 participants