ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "andrykonchin (Andrew Konchin) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "andrykonchin (Andrew Konchin)" <noreply@ruby-lang.org>
Subject: [ruby-core:122296] [Ruby Bug#21374] FrozenError message is inconsistent when a singleton method is defined on a frozen object
Date: Mon, 26 May 2025 14:12:22 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-21374.20250526141222.13553@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-21374.20250526141222.13553@ruby-lang.org>

Issue #21374 has been reported by andrykonchin (Andrew Konchin).

----------------------------------------
Bug #21374: FrozenError message is inconsistent when a singleton method is defined on a frozen object
https://bugs.ruby-lang.org/issues/21374

* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
I would expect a message to contain an object class (e.g. `can't modify frozen <class>: <object#inspect>`) when an ordinary frozen object (non a module or class) is being modified. It works this way in the following example:

```ruby
object = []; object.freeze; object.instance_variable_set(:@a, 42)
# (irb):5:in `instance_variable_set': can't modify frozen Array: [] (FrozenError)
```

But it doesn't in the following example:

```ruby
object = []; object.freeze; def object.x; end
# (irb):4:in `<main>': can't modify frozen object: [] (FrozenError)
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

       reply	other threads:[~2025-05-26 14:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-26 14:12 andrykonchin (Andrew Konchin) via ruby-core [this message]
2025-06-05  8:43 ` [ruby-core:122435] " matz (Yukihiro Matsumoto) via ruby-core

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-all from there: mbox

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

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

  git send-email \
    --in-reply-to=redmine.issue-21374.20250526141222.13553@ruby-lang.org \
    --to=ruby-core@ml.ruby-lang.org \
    --cc=noreply@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 NNTP newsgroup(s).