Commit d36c3f4
Set evaluation result to
This PR makes a change to the thread client to set the `_` local
variable to the result of the last evaluation similar to the behavior in
irb[^1].
The reason `_` doesn't work even when using the `irb` console is because
we leave the `irb` evaluation early if the input should be handled by
the debugger[^2]. Otherwise, we would end up in IRB::Context#evaluate`
and we would call `set_last_value`[^3].
There's a bit of a quirk here when using the `irb` console. I was hoping
in `thread_client` to evaluate the result then set the `_` local
variable and the `@last_value` ivar all in the same method, similar to how `irb`
does it[^1]. However, because we're using the `irb` console we use a new
`irb` `Workspace` which nils out `_` when initialized[^4]. To get around
that, we set the local variable just before evaluating.
[^1]:(https://github.com/ruby/irb/blob/d43c3d764ae439706aa1b26a3ec299cc45eaed5b/lib/irb/context.rb#L460-L465)
[^2]:(https://github.com/ruby/irb/blob/d43c3d764ae439706aa1b26a3ec299cc45eaed5b/lib/irb.rb#L195-L198)
[^3]:(https://github.com/ruby/irb/blob/d43c3d764ae439706aa1b26a3ec299cc45eaed5b/lib/irb/context.rb#L550-L558)
[^4]:(https://github.com/ruby/irb/blob/d43c3d764ae439706aa1b26a3ec299cc45eaed5b/lib/irb/workspace.rb#L81)
This PR was created by Zendesk's Ruby infrastructure team:
Co-authored-by: Benjamin Quorning <bquorning@zendesk.com>
Co-authored-by: Edyta Rozczypała <edyta.rozczypala@zendesk.com>
Co-authored-by: Jury Razumau <jury.razumau@zendesk.com>
Co-authored-by: Leonid Batizhevskii <leonid.batizhevskii@zendesk.com>
Co-authored-by: Luis Manotas <lgerman@gmail.com>
Co-authored-by: Thomas Countz <thomascountz@gmail.com>_ local variable1 parent 14c8a54 commit d36c3f4
File tree
3 files changed
+28
-0
lines changed- lib/debug
- test/console
3 files changed
+28
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
446 | 447 | | |
| 448 | + | |
447 | 449 | | |
448 | 450 | | |
449 | 451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
22 | 34 | | |
23 | 35 | | |
24 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
87 | 101 | | |
88 | 102 | | |
89 | 103 | | |
| |||
0 commit comments