Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when inspect is called but not found in inspector #109

Merged
merged 2 commits into from
Jun 24, 2020

Conversation

pocke
Copy link
Member

@pocke pocke commented Jun 10, 2020

Problem

When an object that doesn't have inspect method is displayed, it raises an error.

irb(main):001:0> BasicObject.new
(Object doesn't support #inspect)
Traceback (most recent call last):
       16: from /home/pocke/.rbenv/versions/trunk/bin/irb:23:in `load'
       15: from /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.8.0/gems/irb-1.2.4/exe/irb:11:in `<top (required)>'
       14: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:399:in `start'
       13: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:470:in `run'
       12: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:470:in `catch'
       11: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:471:in `block in run'
       10: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:536:in `eval_input'
        9: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb/ruby-lex.rb:135:in `each_top_level_statement'
        8: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb/ruby-lex.rb:135:in `catch'
        7: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb/ruby-lex.rb:136:in `block in each_top_level_statement'
        6: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb/ruby-lex.rb:136:in `loop'
        5: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb/ruby-lex.rb:151:in `block (2 levels) in each_top_level_statement'
        4: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:537:in `block in eval_input'
        3: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:695:in `signal_status'
        2: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:541:in `block (2 levels) in eval_input'
        1: from /home/pocke/.rbenv/versions/trunk/lib/ruby/2.8.0/irb.rb:742:in `output_value'
NoMethodError (undefined method `include?' for nil:NilClass)
Maybe IRB bug!

Solution

Make sure the inspector returns a string.

It will display the following output.

irb(main):001:0> BasicObject.new
(Object doesn't support #inspect)
=> 

Note that it is the same with the previous behavior.

irb(main):001:0> RUBY_VERSION
=> "2.6.0"
irb(main):002:0> IRB::VERSION
=> "1.0.0"
irb(main):003:0> BasicObject.new
(Object doesn't support #inspect)
=> 

@aycabta aycabta merged commit dbc291a into ruby:master Jun 24, 2020
@pocke pocke deleted the inspect-not-found branch June 24, 2020 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants