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

Do not match any characters after the dot in an expression #461

Merged
merged 1 commit into from
Dec 28, 2021

Conversation

ono-max
Copy link
Collaborator

@ono-max ono-max commented Dec 26, 2021

Fixes #460.

The reason of this bug is that debugger matches characters after the dot when expressions are constant variables. That's why this PR ensure that debugger doesn't match any characters after the dot.

@@ -745,8 +745,8 @@ def process_dap args
break false
end
} and (message = "Error: Not defined global variable: #{expr.inspect}")
when /\A[A-Z]/
unless result = search_const(b, expr)
when /(\A[A-Z]\w*)/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why don't we use frame_eval to evaluate the expr directly but instead parsing them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frame_eval sometimes changes the value(FYI: #395).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think after 756a2ed#diff-4208807b6db8555c61e42002b3e9c879003c5cfdb32d2b1a285a614b22fdf9d5 the changes made by frame_eval doesn't affect the original program anymore. So in this case it won't reproduce the issue again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think after 756a2ed#diff-4208807b6db8555c61e42002b3e9c879003c5cfdb32d2b1a285a614b22fdf9d5 the changes made by frame_eval doesn't affect the original program anymore. So in this case it won't reproduce the issue again.

Oh, I see. I didn't know that.
However, we can't use frame_eval for the following reasons:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the example case. Are they different because they came from different frames? Or they're different but are evaluated from the same frame?
It looks like search_const may not benefit much from using frame_eval. But I think instance variables, global variables and normal expressions can be evaluated with frame_eval. And making frame_eval take arbitrary frame's binding shouldn't be an issue.

I also see that the CDP server uses a similar but slightly different implementation for evaluation. So if we can utilize it in both server implementation, we can largely simplify these parts and make sure we're aligned on features (such as special locals).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use eval because expression can have side-effect.

@ko1 ko1 merged commit c6e3a82 into ruby:master Dec 28, 2021
@ono-max ono-max deleted the patch-15 branch July 24, 2022 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Debugger raise "NameError" when it hovers the mouse cursor over ".new" in VSCode
3 participants