Bug #2147
closedCannot pp DelegateClass derived classes: undefined method `inspect' NameError
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