From: "jeremyevans0 (Jeremy Evans) via ruby-core" Date: 2025-11-23T08:38:36+00:00 Subject: [ruby-core:123886] [Ruby Bug#21374] FrozenError message is inconsistent when a singleton method is defined on a frozen object Issue #21374 has been updated by jeremyevans0 (Jeremy Evans). I submitted a pull request to fix this issue: https://github.com/ruby/ruby/pull/15303 ---------------------------------------- Bug #21374: FrozenError message is inconsistent when a singleton method is defined on a frozen object https://bugs.ruby-lang.org/issues/21374#change-115291 * 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 : `) 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 `
': 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/