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

Cannot evaluate expression on value definition #103

Closed
ckipp01 opened this issue Sep 23, 2021 · 6 comments · Fixed by #107 or #112
Closed

Cannot evaluate expression on value definition #103

ckipp01 opened this issue Sep 23, 2021 · 6 comments · Fixed by #107 or #112
Assignees
Labels
bug Something isn't working runtime evaluation

Comments

@ckipp01
Copy link
Member

ckipp01 commented Sep 23, 2021

I originally brought this up in scalameta/metals#2959 while testing out the new code evaluation in Metals. I noticed that given a situation where you set a breakpoint before a variable is assigned, any evaluation is then blocked since it seems to not find that variable. A picture is worth a thousand words so you can see what I mean here:

Screenshot 2021-09-23 at 18 33 52

Notice that I'm stopped on the line containing val y = x * 3. I'm just trying to evaluate 3 * 6 here, and I'd expect that to work instead of getting the message about not found: value y.

The same thing happens if you try to access another variable that should already be assigned like x in this example:

Screenshot 2021-09-23 at 19 03 52

Notice that it is there when looking at the variables, but when I try to access it via just x where the expressions are entered at the bottom, I again see the message.

I tested this with the pr in Metals here: scalameta/metals#2959 while using nvim-metals, which integrates with nvim-dap.

As a total aside, great job on this so far. It's fantastic to see this working. In the above examples if I just step over once, then everything works.

2021-09-23 18 27 03

@tgodzik
Copy link
Collaborator

tgodzik commented Oct 1, 2021

I can still reproduce the issue in Metals, can you take a second look @tdudzik ?

@tgodzik tgodzik reopened this Oct 1, 2021
@ckipp01
Copy link
Member Author

ckipp01 commented Oct 1, 2021

I can still reproduce the issue in Metals, can you take a second look @tdudzik ?

Just a sanity check, but make sure you have the new bloop that it brought in running and not the old one. I've made that mistake more than once when testing this out 😆

@tdudzik
Copy link
Contributor

tdudzik commented Oct 1, 2021

Actually, it doesn't always work. It seems there were two issues with that case and I've fixed only one of them. The other one should be fixed soon.

@adpi2
Copy link
Member

adpi2 commented Oct 1, 2021

@tdudzik Can you share the reproduction case?

@tdudzik
Copy link
Contributor

tdudzik commented Oct 1, 2021

@adpi2 it seems that it works only when a value/variable is defined but it's not used, so e.g.:
it's going to work:

val a = 1 // breakpoint
println("Hello, World!")

it's not going to work:

val a = 1 // breakpoint
println(a)

The reason is that in InsertExpression compilation phase expression is wrapped in a block so the second example will be converted to something like this:

{
1 + 2 // expression
val a = 1 
}
println(a)

and then the value a is not accessible in the line println(a) and because of that error is returned.

@tgodzik
Copy link
Collaborator

tgodzik commented Oct 1, 2021

Do we need to have val a = 1 in the block? Could we move it outside it?

@adpi2 adpi2 changed the title Unexpected "not found value" message. Cannot evaluate expression on value definition Oct 5, 2021
@adpi2 adpi2 added bug Something isn't working runtime evaluation labels Oct 6, 2021
@adpi2 adpi2 closed this as completed in #112 Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working runtime evaluation
Projects
None yet
4 participants