Project

General

Profile

Actions

Feature #16129

closed

Call initialize_clone with freeze: false if clone called with freeze: false

Added by jeremyevans0 (Jeremy Evans) about 5 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:94555]

Description

This makes it possible for initialize_clone to correctly not freeze internal state if the freeze: false keyword is passed to clone.

If clone is called with freeze: true or no keyword, do not pass a second argument to initialize_clone to keep backwards compatibility.

This makes it so that external libraries that override initialize_clone but do not support the freeze keyword will fail with ArgumentError if passing freeze: false to clone. I think that is better than the current behavior, which succeeds but results in an unfrozen object with frozen internals.

The attached patch implements this support and fixes related issues in set and delegate in stdlib.


Files

initialize-clone-freeze-false.patch (8.1 KB) initialize-clone-freeze-false.patch jeremyevans0 (Jeremy Evans), 08/26/2019 04:20 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14266: Set#clone(freeze: false) makes frozen internal hashClosedknu (Akinori MUSHA)Actions
Actions #1

Updated by jeremyevans0 (Jeremy Evans) about 5 years ago

  • Related to Bug #14266: Set#clone(freeze: false) makes frozen internal hash added
Actions #2

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0