ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:105276] [Ruby master Bug#18170] Exception#inspect should not include newlines
@ 2021-09-16  2:34 mame (Yusuke Endoh)
  2021-09-16  8:42 ` [ruby-core:105291] " mame (Yusuke Endoh)
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: mame (Yusuke Endoh) @ 2021-09-16  2:34 UTC (permalink / raw)
  To: ruby-core

Issue #18170 has been reported by mame (Yusuke Endoh).

----------------------------------------
Bug #18170: Exception#inspect should not include newlines
https://bugs.ruby-lang.org/issues/18170

* Author: mame (Yusuke Endoh)
* Status: Open
* Priority: Normal
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Is this intentional?

```
p StandardError.new("foo\nbar")
#=>
# #<StandardError: foo
# bar>
```

I expect `#inspect` returns a one-line string. How about returning `#<StandardError: "foo\nbar">` 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
#=>
# #<Foo:0x00007f15aeb4ba48 @exception=#<NameError: undefined local variable or method `exampl' for #<Foo:0x00007f15aeb4ba48 ...>
#
#     @exception = begin; exampl; rescue Exception; $!; end
#                         ^^^^^^
# Did you mean?  example>>
```

This issue was originally found by @ioquatix 



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2022-09-23  7:40 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16  2:34 [ruby-core:105276] [Ruby master Bug#18170] Exception#inspect should not include newlines mame (Yusuke Endoh)
2021-09-16  8:42 ` [ruby-core:105291] " mame (Yusuke Endoh)
2021-09-16 10:16 ` [ruby-core:105295] " ioquatix (Samuel Williams)
2021-09-17  8:04 ` [ruby-core:105323] " mame (Yusuke Endoh)
2021-09-24 18:56 ` [ruby-core:105414] " Eregon (Benoit Daloze)
2021-09-25 16:58 ` [ruby-core:105418] " mame (Yusuke Endoh)
2021-09-26 12:07 ` [ruby-core:105424] " Eregon (Benoit Daloze)
2021-09-26 20:17 ` [ruby-core:105426] " ioquatix (Samuel Williams)
2021-09-26 20:18 ` [ruby-core:105427] " ioquatix (Samuel Williams)
2021-09-27  9:59 ` [ruby-core:105445] " Eregon (Benoit Daloze)
2021-09-27 10:02 ` [ruby-core:105446] " Eregon (Benoit Daloze)
2021-09-29  9:47 ` [ruby-core:105485] " ioquatix (Samuel Williams)
2021-10-21  5:09 ` [ruby-core:105711] " matz (Yukihiro Matsumoto)
2021-10-25  8:59 ` [ruby-core:105778] " mame (Yusuke Endoh)
2021-10-25 10:20 ` [ruby-core:105786] " ioquatix (Samuel Williams)
2021-10-25 15:07 ` [ruby-core:105790] " mame (Yusuke Endoh)
2021-10-26  8:59 ` [ruby-core:105804] " ioquatix (Samuel Williams)
2021-11-10 11:03 ` [ruby-core:106003] " Eregon (Benoit Daloze)
2021-11-10 11:10 ` [ruby-core:106004] " ioquatix (Samuel Williams)
2021-11-10 11:10 ` [ruby-core:106005] " Eregon (Benoit Daloze)
2021-11-10 11:15 ` [ruby-core:106006] " Eregon (Benoit Daloze)
2021-11-11 13:52 ` [ruby-core:106029] " mame (Yusuke Endoh)
2021-11-30  7:32 ` [ruby-core:106333] " mame (Yusuke Endoh)
2022-06-07  9:25 ` [ruby-core:108791] " st0012 (Stan Lo)
2022-06-07  9:58 ` [ruby-core:108792] " ioquatix (Samuel Williams)
2022-06-07 20:19 ` [ruby-core:108797] " st0012 (Stan Lo)
2022-06-08  0:27 ` [ruby-core:108798] " ioquatix (Samuel Williams)
2022-09-23  7:11 ` [ruby-core:110034] " ioquatix (Samuel Williams)
2022-09-23  7:40 ` [ruby-core:110037] " mame (Yusuke Endoh)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).