Actions
Bug #11493
closedIRB/Ruby completely exits when attempting to use NoMethodError exception in BasicObject
ruby -v:
2.2.0
Description
Summary¶
Was playing around with BasicObject to implement my own undefined method message and found this issue in IRB
$ ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
$ irb
2.2.0 :002 > class BasicObject
2.2.0 :003?> def method_missing(name, *args, &block)
2.2.0 :004?> raise(NoMethodError, " '#{name}' is an undefined method, dude!")
2.2.0 :005?> end
2.2.0 :006?> end
=> :method_missing
2.2.0 :008 > 234234.asdasdasd
NameError: uninitialized constant BasicObject::NoMethodError
(irb):4:in `method_missing': uninitialized constant BasicObject::NoMethodError (NameError)
from /Users/home/.rvm/scripts/irbrc.rb:32:in `initialize'
from /Users/home/.rvm/scripts/irbrc.rb:32:in `open'
from /Users/home/.rvm/scripts/irbrc.rb:32:in `block in <top (required)>'
(irb):4:in `method_missing': uninitialized constant BasicObject::NoMethodError (NameError)
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb/workspace.rb:106:in `sub'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb/workspace.rb:106:in `filter_backtrace'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:511:in `block (3 levels) in eval_input'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:510:in `each'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:510:in `block (2 levels) in eval_input'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:623:in `signal_status'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:486:in `block in eval_input'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb/ruby-lex.rb:245:in `block (2 levels) in each_top_level_statement'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `loop'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `block in each_top_level_statement'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `catch'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `each_top_level_statement'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:485:in `eval_input'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:395:in `block in start'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:394:in `catch'
from /Users/home/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/irb.rb:394:in `start'
from /Users/home/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'
$ echo $?
1
Expected Results¶
I expect IRB to handle Ruby errors without exiting completely. The same way "foo".asdfasdf() raises a NoMethodError, but doesn't actually completely die.
Actual Results¶
Fatal error resulting in the Ruby process exiting.
Actions
Like0
Like0Like0Like0