From: Marc-Andre Lafortune Date: 2012-02-17T04:31:08+09:00 Subject: [ruby-core:42695] [ruby-trunk - Bug #6037][Rejected] #freeze bug Issue #6037 has been updated by Marc-Andre Lafortune. Status changed from Open to Rejected Rejecting, as this is per spec. Behavior can not be changed without breaking a lot of code. Note that I also would like a deep freeze (see http://bugs.ruby-lang.org/issues/show/2509 ) but that is a feature request, not a bug report. ---------------------------------------- Bug #6037: #freeze bug https://bugs.ruby-lang.org/issues/6037 Author: Denis de Bernardy Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: 1.9.3 freeze should deep freeze, to avoid inconsistent behavior: array = ['a', 'b'].freeze array[0] = 'b' array[0].gsub!(/.+/s, 'b') array >> RUBY_VERSION => "1.9.3" >> array = ['a', 'b'].freeze => ["a", "b"] >> array[0] = 'b' RuntimeError: can't modify frozen Array from (irb):269:in `[]=' from (irb):269 from /opt/local/bin/irb:12:in `
' >> array[0].gsub!(/.+/s, 'b') => "b" >> array => ["b", "b"] -- http://bugs.ruby-lang.org/