ruby / debug

Debugging functionality for Ruby
BSD 2-Clause "Simplified" License
1.14k stars 127 forks source link

fix(console): Pass IO-like object to `pp` (pretty-print) #958

Closed DerekStride closed 1 year ago

DerekStride commented 1 year ago

Description

Passing a String object to pp via IRB::ColorPrinter.pp raises an error if the object implementing #pretty_print(pp) expects the pp.output object to act like an IO object. It raises this error:

NoMethodError: private method `puts' called for "":String> rescued during inspection

Example

TreeStand::Node#pretty_print (calls io.puts)

DerekStride commented 1 year ago

Closing, looks like PP#output is expected to respond to << instead.

https://ruby-doc.org/3.2.2/stdlibs/prettyprint/PrettyPrint.html