From: "Eregon (Benoit Daloze)" Date: 2021-11-10T11:10:58+00:00 Subject: [ruby-core:106005] [Ruby master Bug#18170] Exception#inspect should not include newlines Issue #18170 has been updated by Eregon (Benoit Daloze). BTW it seems `irb` disables `error_highlight` somehow: ``` $ ruby -ve 'self.instance_off' ruby 3.1.0dev (2021-11-08T13:15:21Z master bd2674ad33) [x86_64-linux] -e:1:in `
': undefined method `instance_off' for main:Object (NoMethodError) self.instance_off ^^^^^^^^^^^^^ Did you mean? instance_of? ``` vs ``` $ irb irb(main):001:0> self.instance_off (irb):1:in `
': undefined method `instance_off' for main:Object (NoMethodError) Did you mean? instance_of? from /home/eregon/prefix/ruby-master/lib/ruby/gems/3.1.0/gems/irb-1.3.8.pre.11/exe/irb:11:in `' from /home/eregon/.rubies/ruby-master/bin/irb:25:in `load' from /home/eregon/.rubies/ruby-master/bin/irb:25:in `
' ``` ---------------------------------------- Bug #18170: Exception#inspect should not include newlines https://bugs.ruby-lang.org/issues/18170#change-94553 * Author: mame (Yusuke Endoh) * Status: Assigned * Priority: Normal * Assignee: mame (Yusuke Endoh) * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Is this intentional? ``` p StandardError.new("foo\nbar") #=> # # ``` I expect `#inspect` returns a one-line string. How about returning `#` or something? Recently, multi-line error messages have been increasing by the introduction of did_you_mean and error_highlight. Printing an object that contains such an exception leads to a tricky output: ``` class Foo def initialize @exception = begin; exampl; rescue Exception; $!; end end def example end end p Foo.new #=> # # # # @exception = begin; exampl; rescue Exception; $!; end # ^^^^^^ # Did you mean? example>> ``` This issue was originally found by @ioquatix -- https://bugs.ruby-lang.org/ Unsubscribe: