You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pry and IRB have a feature in which _ is always set the the value of the last expression. While I realize it may not make sense to do this with debug commands, it would be nice if the feature was there at least for Ruby expressions. The current behavior seems to be setting _ to the last error, but seemingly only for debug commands like ls. This is kind of a bug in the irb_console since IRB has this feature normally but it stops working after entering debug mode.
Additional context
Shell session:
irb(#<Foobar:0x000000011efeb9f0>):001> 3+3=>6irb(#<Foobar:0x000000011efeb9f0>):002> puts _6=> nil
irb(#<Foobar:0x000000011efeb9f0>):003> 4+4=>8irb(#<Foobar:0x000000011efeb9f0>):004> info(rdbg:irb)info
%self=#<Foobar:0x000000011efeb9f0 @foo="bar">@foo="bar"irb:rdbg(#<Foobar:0x000000011efeb9f0>):002> puts _
nil
irb:rdbg(#<Foobar:0x000000011efeb9f0>):003> 4+48irb:rdbg(#<Foobar:0x000000011efeb9f0>):004> puts _
nil
irb:rdbg(#<Foobar:0x000000011efeb9f0>):005> 4+48irb:rdbg(#<Foobar:0x000000011efeb9f0>):006> info
%self=#<Foobar:0x000000011efeb9f0 @foo="bar">_= nil
@foo="bar"irb:rdbg(#<Foobar:0x000000011efeb9f0>):007> ls BarTraceback(mostrecentcalllast):
24: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:212:in`block in activate' 23: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:254:in `session_server_main' 22: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:365:in `process_event'21: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:403:in`wait_command_loop' 20: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:403:in `loop' 19: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:404:in `block in wait_command_loop'18: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:444:in`wait_command' 15: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:1981:in `intercept_trap_sigint' 4: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/irb_integration.rb:9:in `evaluate'(irb):7:in`set_foo': uninitialized constant Foobar::Bar (NameError)`irb:rdbg(#<Foobar:0x000000011efeb9f0>):008> puts _uninitializedconstantFoobar::Barnilirb:rdbg(#<Foobar:0x000000011efeb9f0>):009> ls BarTraceback(mostrecentcalllast):
24: from/Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:212:in`block in activate' 23: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:254:in `session_server_main' 22: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:365:in `process_event'21: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:403:in`wait_command_loop' 20: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:403:in `loop' 19: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:404:in `block in wait_command_loop'18: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:444:in`wait_command' 15: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/session.rb:1981:in `intercept_trap_sigint' 4: from /Users/joesharp/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/debug-1.9.1/lib/debug/irb_integration.rb:9:in `evaluate'(irb):9:in`set_foo': uninitialized constant Foobar::Bar (NameError)`irb:rdbg(#<Foobar:0x000000011efeb9f0>):010> info
%self=#<Foobar:0x000000011efeb9f0 @foo="bar">_=#<NameError: uninitialized constant Foobar::Bar>@foo="bar"irb:rdbg(#<Foobar:0x000000011efeb9f0>):011> Bar.methodsevalerror: uninitializedconstantFoobar::Bar(rdbg)/scratch.rb:1:in`set_foo'`nilirb:rdbg(#<Foobar:0x000000011efeb9f0>):012> info
%self=#<Foobar:0x000000011efeb9f0 @foo="bar">_= nil
@foo="bar"irb:rdbg(#<Foobar:0x000000011efeb9f0>):013> Bar.methodsevalerror: uninitializedconstantFoobar::Bar(rdbg)/scratch.rb:1:in`set_foo'`nilirb:rdbg(#<Foobar:0x000000011efeb9f0>):014> puts _nil
The text was updated successfully, but these errors were encountered:
Additionally, please note in the "Session Variables" section of https://docs.ruby-lang.org/en/2.2.0/IRB.html#module-IRB-label-Commands that IRB also supports __ (double underscore) and __[line_no] when configured to do so. It always supports the single underscore for the last value though.
Your proposal
Pry and IRB have a feature in which
_
is always set the the value of the last expression. While I realize it may not make sense to do this with debug commands, it would be nice if the feature was there at least for Ruby expressions. The current behavior seems to be setting_
to the last error, but seemingly only for debug commands likels
. This is kind of a bug in the irb_console since IRB has this feature normally but it stops working after entering debug mode.Additional context
Shell session:
The text was updated successfully, but these errors were encountered: