Feature #2018

[irb] BasicObject.new doesn't have an inspect

Added by Daniel Bovensiepen over 4 years ago. Updated almost 3 years ago.

[ruby-core:25200]
Status:Closed
Priority:Low
Assignee:Keiju Ishitsuka
Category:lib
Target version:2.0.0

Description

=begin
Using BasicObject.new in irb:

daniel@boviAir# ruby19 --version
ruby 1.9.2dev (2009-08-30 trunk 24718) [i386-darwin9.8.0]
daniel@boviAir# irb19 --version
irb 0.9.6(09/06/30)
daniel@boviAir# irb19
irb(main):001:0> BasicObject.new

Produce an Exception due to the fact that inspect doesn't exist in the BasicObject:

NoMethodError: undefined method inspect' for #<BasicObject:0x4b2738>
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/inspector.rb:84:in
block in module:IRB'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/inspector.rb:30:in call'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/inspector.rb:30:in
inspectvalue'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/context.rb:259:in inspect_last_value'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:309:in
output
value'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:158:in block (2 levels) in eval_input'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:271:in
signalstatus'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:154:in block in eval_input'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/ruby-lex.rb:244:in
block (2 levels) in each
toplevelstatement'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/ruby-lex.rb:230:in loop'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/ruby-lex.rb:230:in
block in eachtoplevelstatement'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in catch'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in
each
toplevelstatement'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:153:in eval_input'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:70:in
block in start'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:69:in catch'
from /Users/danielbovensiepen/Programs/ruby19/lib/ruby/1.9.1/irb.rb:69:in
start'
from /Users/danielbovensiepen/Programs/ruby19/bin/irb19:12:in `'Maybe IRB bug!!

In the attachment is a patch for catching this exception.
=end

basicobject_irb.patch Magnifier - Patch for catching inspect exception in irb (685 Bytes) Daniel Bovensiepen, 08/31/2009 02:43 AM

History

#1 Updated by David Black over 4 years ago

=begin
Hi --

On Mon, 31 Aug 2009, Daniel Bovensiepen wrote:

Bug #2018: [irb] BasicObject.new doesn't have an inspect
http://redmine.ruby-lang.org/issues/show/2018

Why is that a bug?

David

--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Ruby/Rails training, mentoring, consulting, code-review
Latest book: The Well-Grounded Rubyist (http://www.manning.com/black2)

September Ruby training in NJ has been POSTPONED. Details to follow.

=end

#2 Updated by Hongli Lai over 4 years ago

=begin
I thought the whole point of BasicObject is that it doesn't have any methods.
=end

#3 Updated by Yukihiro Matsumoto over 4 years ago

=begin
Hi,

In message "Re: Re: [Bug #2018] [irb] BasicObject.new doesn't have an inspect"
on Mon, 31 Aug 2009 02:49:19 +0900, "David A. Black" dblack@rubypal.com writes:

|> Bug #2018: [irb] BasicObject.new doesn't have an inspect
|> http://redmine.ruby-lang.org/issues/show/2018
|
|Why is that a bug?

I think it's not the point. BasicObject has no method (with a few
exception) by its definition. But irb should handle objects without
inspect defined.

                        matz.

=end

#4 Updated by David Black over 4 years ago

=begin
On Mon, 31 Aug 2009, Yukihiro Matsumoto wrote:

Hi,

In message "Re: Re: [Bug #2018] [irb] BasicObject.new doesn't have an inspect"
on Mon, 31 Aug 2009 02:49:19 +0900, "David A. Black" dblack@rubypal.com writes:

|> Bug #2018: [irb] BasicObject.new doesn't have an inspect
|> http://redmine.ruby-lang.org/issues/show/2018
|
|Why is that a bug?

I think it's not the point. BasicObject has no method (with a few
exception) by its definition. But irb should handle objects without
inspect defined.

Ah, OK -- I didn't catch onto that.

Actually I really like doing:

>> b = BasicObject.new

in irb when I'm teaching 1.9 -- very dramatic way to demonstrate the
basicness of BasicObject :-) But I can understand that it should
probably be handled more gracefully.

David

--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Ruby/Rails training, mentoring, consulting, code-review
Latest book: The Well-Grounded Rubyist (http://www.manning.com/black2)

September Ruby training in NJ has been POSTPONED. Details to follow.

=end

#5 Updated by Yuki Sonoda over 4 years ago

  • Assignee set to Keiju Ishitsuka
  • Target version set to 2.0.0

=begin
It is not a bug. But I think enhancement for irb is possible.
What kind of handling do you want?
=end

#6 Updated by Yukihiro Matsumoto over 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r24779.
=end

Also available in: Atom PDF