Include inspect value of object in FrozenError messages
FrozenError#receiver was added recently for getting the related object programmatically. However, there are cases where FrozenError is raised and not handled, and in those cases the resulting error messages lack detail, which makes debugging the error more difficult, especially in cases where the error is not easily reproducible. This includes the inspect value of the frozen object in
FrozenError messages, which should make debugging simpler.
class A; end A.freeze def A.a; end # can't modify frozen Class 'a'.freeze << 'b' # can't modify frozen String
class A; end A.freeze def A.a; end # can't modify frozen Class: A 'a'.freeze << 'b' # can't modify frozen String: "a"
Attached is a patch that implements this feature. If there are no objections, I plan on committing this in about a week.