Project

General

Profile

Actions

Bug #2147

closed

Cannot pp DelegateClass derived classes: undefined method `inspect' NameError

Added by pilcrow (Mike Pomraning) about 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
ruby -v:
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
[ruby-core:25804]

Description

=begin
pp derived_from_delegate_class fails with a NameError under 1.9.1, apparently unable to find the method #inspect(), though a direct call to that method works fine:

=== begin ===
require 'delegate'
require 'pp'

class A < DelegateClass(Array); end

puts "ruby-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})"
puts A.new([]).inspect
pp A.new([])
=== end ===

Compare:

$ ruby-1.8.7 delegate-inspect.rb
ruby-1.8.7-p160 (i686-linux)
[]
[]

$ ruby-1.9 delegate-inspect.rb
ruby-1.9.1-p243 (i686-linux)
[]
/opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:286:in method': undefined method inspect' for class A' (NameError) from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:286:in call'
from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:286:in pretty_print' from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:154:in block in pp'
from /opt/ruby-1.9.1/lib/ruby/1.9.1/prettyprint.rb:200:in block (2 levels) in group' from /opt/ruby-1.9.1/lib/ruby/1.9.1/prettyprint.rb:227:in nest'
from /opt/ruby-1.9.1/lib/ruby/1.9.1/prettyprint.rb:200:in block in group' from /opt/ruby-1.9.1/lib/ruby/1.9.1/prettyprint.rb:212:in group_sub'
from /opt/ruby-1.9.1/lib/ruby/1.9.1/prettyprint.rb:199:in group' from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:154:in pp'
from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:77:in block in pp' from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:121:in guard_inspect_key'
from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:77:in pp' from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:59:in block in pp'
from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:59:in each' from /opt/ruby-1.9.1/lib/ruby/1.9.1/pp.rb:59:in pp'
from delegate-inspect.rb:8:in `'
=end


Files

delegate-inspect.rb (173 Bytes) delegate-inspect.rb pilcrow (Mike Pomraning), 09/27/2009 12:26 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0