Do not match any characters after the dot in an expression#461
Do not match any characters after the dot in an expression#461ko1 merged 1 commit intoruby:masterfrom
Conversation
| } and (message = "Error: Not defined global variable: #{expr.inspect}") | ||
| when /\A[A-Z]/ | ||
| unless result = search_const(b, expr) | ||
| when /(\A[A-Z]\w*)/ |
There was a problem hiding this comment.
just curious, why don't we use frame_eval to evaluate the expr directly but instead parsing them?
There was a problem hiding this comment.
frame_eval sometimes changes the value(FYI: #395).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
frame_evaluses current_frame, but we have to get a frame from request.- Even current_frame is the same as the target frame, we can't sometimes get the correct value such as instance of class. In the following case, showed value and value in backtrace information are not same.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
We shouldn't use eval because expression can have side-effect.

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.