提交 0d019afc 编写于 作者: A Andrew White

Merge pull request #18551 from aditya-kapoor/fix-frozen-hwia

Fix assignment for frozen value in HWIA
* Duplicate frozen array when assigning it to a HashWithIndifferentAccess so
that it doesn't raise a `RuntimeError` when calling `map!` on it in `convert_value`.
Fixes #18550.
*Aditya Kapoor*
* Add missing time zone definitions for Russian Federation and sync them
with `zone.tab` file from tzdata version 2014j (latest).
......
......@@ -267,7 +267,7 @@ def convert_value(value, options = {})
value.nested_under_indifferent_access
end
elsif value.is_a?(Array)
unless options[:for] == :assignment
if options[:for] != :assignment || value.frozen?
value = value.dup
end
value.map! { |e| convert_value(e, options) }
......
......@@ -7,4 +7,11 @@ def test_reverse_merge
hash.reverse_merge! key: :new_value
assert_equal :old_value, hash[:key]
end
def test_frozen_value
value = [1, 2, 3].freeze
hash = {}.with_indifferent_access
hash[:key] = value
assert_equal hash[:key], value
end
end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册