Project

General

Profile

Feature #16175

Object#clone(freeze: true) is inconsistent with Object#clone(freeze: false)

Added by zverok (Victor Shepelev) 9 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:95021]

Description

In #12300, the new keyword freeze: was introduced, allowing this:

h = {}.freeze
h.clone.frozen?
# => true
h.clone(freeze: false).frozen?
# => false

Though, it turns to me that behavior is not symmetric:

h = {}
h.frozen?
# => false
h.clone.frozen?
# => false
h.clone(freeze: true).frozen?
# => false -- I expected true here!

I wonder, if it is "by design" and should be addressed in docs, or just an implementation inconsistency that can be fixed?


Files

freeze-true.patch (1.47 KB) freeze-true.patch zverok (Victor Shepelev), 09/22/2019 09:59 AM
clone-freeze-true-16175.patch (4.42 KB) clone-freeze-true-16175.patch jeremyevans0 (Jeremy Evans), 09/23/2019 11:06 PM

Also available in: Atom PDF