ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "nobu (Nobuyoshi Nakada)" <noreply@ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Subject: [ruby-core:111240] [Ruby master Bug#19167] Object#inspect does not correctly show NilClass TrueClass and FalseClass stored in instance variables
Date: Thu, 08 Dec 2022 08:03:22 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-100530.20221208080320.10330@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19167.20221201181036.10330@ruby-lang.org

Issue #19167 has been updated by nobu (Nobuyoshi Nakada).


Essentially, this behavior is an "unofficial" feature for internal use only (not expected to be documented), so it has not been described in doc/extension.rdoc. 
>   Note: In the format string, "%"PRIsVALUE can be used for Object#to_s
>   (or Object#inspect if '+' flag is set) output (and related argument
>   must be a VALUE).  Since it conflicts with "%i", for integers in
>   format strings, use "%d".

And I inadvertently overlooked this side-effect.

As the conclusion, I'll remove this behavior and use another way for the error messages which used this behavior.
And I'll mark the code in ruby-spec with `ruby_bug`.

----------------------------------------
Bug #19167: Object#inspect does not correctly show NilClass TrueClass and FalseClass stored in instance variables
https://bugs.ruby-lang.org/issues/19167#change-100530

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin20]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------

~~~ruby
Object.new.instance_eval do
  @a = nil
  @b = NilClass
  @c = true
  @d = TrueClass
  @e = [nil, NilClass, true, TrueClass]
  puts self.inspect
end
# actual
# => #<Object:0x2f15e3c8 @a=nil, @b=nil, @c=true, @d=true, @e=[nil, NilClass, true, TrueClass]>
# expected
# => #<Object:0x2f15e3c8 @a=nil, @b=NilClass, @c=true, @d=TrueClass, @e=[nil, NilClass, true, TrueClass]>
~~~

---Files--------------------------------
0001-Fix-Object-inspect-with-NilClass-as-an-ivar.patch (751 Bytes)


-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

      parent reply	other threads:[~2022-12-08  8:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 18:10 [ruby-core:111135] [Ruby master Bug#19167] Object#inspect does not correctly show NilClass TrueClass and FalseClass stored in instance variables tompng (tomoya ishida)
2022-12-06 18:27 ` [ruby-core:111222] " eightbitraptor (Matthew Valentine-House)
2022-12-06 21:19 ` [ruby-core:111224] " alanwu (Alan Wu)
2022-12-07 16:02 ` [ruby-core:111232] " eightbitraptor (Matthew Valentine-House)
2022-12-07 16:35 ` [ruby-core:111233] " eightbitraptor (Matthew Valentine-House)
2022-12-07 16:49 ` [ruby-core:111234] " nobu (Nobuyoshi Nakada)
2022-12-08  8:03 ` nobu (Nobuyoshi Nakada) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-100530.20221208080320.10330@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=ruby-core@ml.ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).