Project

General

Profile

Actions

Bug #21374

open

FrozenError message is inconsistent when a singleton method is defined on a frozen object

Added by andrykonchin (Andrew Konchin) 2 days ago. Updated 2 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:122296]

Description

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:

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:

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

Updated by andrykonchin (Andrew Konchin) 2 days ago

  • ruby -v set to 3.4.2
Actions

Also available in: Atom PDF

Like0
Like0