* [ruby-core:122296] [Ruby Bug#21374] FrozenError message is inconsistent when a singleton method is defined on a frozen object
@ 2025-05-26 14:12 andrykonchin (Andrew Konchin) via ruby-core
2025-06-05 8:43 ` [ruby-core:122435] " matz (Yukihiro Matsumoto) via ruby-core
0 siblings, 1 reply; 2+ messages in thread
From: andrykonchin (Andrew Konchin) via ruby-core @ 2025-05-26 14:12 UTC (permalink / raw)
To: ruby-core; +Cc: andrykonchin (Andrew Konchin)
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:122435] [Ruby Bug#21374] FrozenError message is inconsistent when a singleton method is defined on a frozen object
2025-05-26 14:12 [ruby-core:122296] [Ruby Bug#21374] FrozenError message is inconsistent when a singleton method is defined on a frozen object andrykonchin (Andrew Konchin) via ruby-core
@ 2025-06-05 8:43 ` matz (Yukihiro Matsumoto) via ruby-core
0 siblings, 0 replies; 2+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2025-06-05 8:43 UTC (permalink / raw)
To: ruby-core; +Cc: matz (Yukihiro Matsumoto)
Issue #21374 has been updated by matz (Yukihiro Matsumoto).
I agree with you. It should be consistent (and I prefer `can't modify frozen Array: [] (FrozenError)` message). But there might be some internal reason. We have to investigate first.
Matz.
----------------------------------------
Bug #21374: FrozenError message is inconsistent when a singleton method is defined on a frozen object
https://bugs.ruby-lang.org/issues/21374#change-113616
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* ruby -v: 3.4.2
* 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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-05 8:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-26 14:12 [ruby-core:122296] [Ruby Bug#21374] FrozenError message is inconsistent when a singleton method is defined on a frozen object andrykonchin (Andrew Konchin) via ruby-core
2025-06-05 8:43 ` [ruby-core:122435] " matz (Yukihiro Matsumoto) via ruby-core
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).