From: nov@... Date: 2018-05-11T08:49:41+00:00 Subject: [ruby-core:86989] [Ruby trunk Bug#14749] IRB: `_` is not updated after exception raised Issue #14749 has been reported by no6v (Nobuhiro IMAI). ---------------------------------------- Bug #14749: IRB: `_` is not updated after exception raised https://bugs.ruby-lang.org/issues/14749 * Author: no6v (Nobuhiro IMAI) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.0dev (2018-05-10 trunk 63393) [x86_64-linux] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- After r63150, once exception raised, irb holds that exception to `_` instead of the last evaluated value. ~~~irb $ irb -f irb(main):001:0> RUBY_VERSION => "2.6.0" irb(main):002:0> _ => "2.6.0" irb(main):003:0> raise RUBY_RELEASE_DATE Traceback (most recent call last): (snip) 1: from (irb):3 RuntimeError (2018-05-10) irb(main):004:0> _ => # irb(main):005:0> RUBY_REVISION => 63393 irb(main):006:0> _ => # ~~~ The last result of above example should be 63393. The following patch works fine for me, but I'm not sure it is enough or not. ~~~diff diff --git a/lib/irb.rb b/lib/irb.rb index 98bcac016d..a10f9e894a 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -501,6 +501,8 @@ def eval_input if exc last_error = exc handle_exception(exc) + else + last_error = nil end end end ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: