Project

General

Profile

Actions

Bug #14266

closed

Set#clone(freeze: false) makes frozen internal hash

Added by znz (Kazuhiro NISHIYAMA) almost 7 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-01-01 trunk 61537) [x86_64-darwin16]
[ruby-core:84581]
Tags:

Description

% irb -r irb/completion --simple-prompt
>> require 'set'
=> true
>> set=Set[].freeze.clone(freeze: false)
=> #<Set: {}>
>> set.frozen?
=> false
>> set.instance_variable_get(:@hash).frozen?
=> true

In Set#initialize_clone, clone hash without freeze keyword argument.
But I think there is no easy way how to know freeze keyword argument value in initialize_clone.

  # Clone internal hash.
  def initialize_clone(orig)
    super
    @hash = orig.instance_variable_get(:@hash).clone
  end

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #16129: Call initialize_clone with freeze: false if clone called with freeze: falseClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0