[ruby-core:124417] [Ruby Bug#21819] A Data object should be frozen even if it has no members
Issue #21819 has been reported by dazuma (Daniel Azuma). ---------------------------------------- Bug #21819: A Data object should be frozen even if it has no members https://bugs.ruby-lang.org/issues/21819 * Author: dazuma (Daniel Azuma) * Status: Open * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Data objects with at least one member are currently automatically frozen on construction, and shareable if all members are shareable. However, a Data object with no members is not frozen on construction. I would expect such an object similarly to be frozen (and also shareable since it has no non-shareable members). ``` Foo = Data.define(:foo) Foo.new(1).frozen? # => true Bar = Data.define Bar.new.frozen? # => false ``` -- https://bugs.ruby-lang.org/
Issue #21819 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ruby_4_0 commit:6273c59a6e1f8587e549d5a5f44fd9363e6eb018 merged revision(s) commit:d7a6ff8224519005d2deeb3f4e98689a8a0835ad. ---------------------------------------- Bug #21819: A Data object should be frozen even if it has no members https://bugs.ruby-lang.org/issues/21819#change-116044 * Author: dazuma (Daniel Azuma) * Status: Closed * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ---------------------------------------- Data objects with at least one member are currently automatically frozen on construction, and shareable if all members are shareable. However, a Data object with no members is not frozen on construction. I would expect such an object similarly to be frozen (and also shareable since it has no non-shareable members). ``` Foo = Data.define(:foo) Foo.new(1).frozen? # => true Bar = Data.define Bar.new.frozen? # => false ``` -- https://bugs.ruby-lang.org/
Issue #21819 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE to 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_3_4 commit:d5ca99a71ccb170db08e4b610d661ce3a18626f2 merged revision(s) commit:d7a6ff8224519005d2deeb3f4e98689a8a0835ad. ---------------------------------------- Bug #21819: A Data object should be frozen even if it has no members https://bugs.ruby-lang.org/issues/21819#change-116209 * Author: dazuma (Daniel Azuma) * Status: Closed * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- Data objects with at least one member are currently automatically frozen on construction, and shareable if all members are shareable. However, a Data object with no members is not frozen on construction. I would expect such an object similarly to be frozen (and also shareable since it has no non-shareable members). ``` Foo = Data.define(:foo) Foo.new(1).frozen? # => true Bar = Data.define Bar.new.frozen? # => false ``` -- https://bugs.ruby-lang.org/
Issue #21819 has been updated by hsbt (Hiroshi SHIBATA). Backport changed from 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE, 4.0: DONE to 3.2: REQUIRED, 3.3: DONE, 3.4: DONE, 4.0: DONE ruby_3_3 commit:f97da5bee650192897399eff2f372e46170ce72a merged revision(s) commit:d7a6ff8224519005d2deeb3f4e98689a8a0835ad. ---------------------------------------- Bug #21819: A Data object should be frozen even if it has no members https://bugs.ruby-lang.org/issues/21819#change-116825 * Author: dazuma (Daniel Azuma) * Status: Closed * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.2: REQUIRED, 3.3: DONE, 3.4: DONE, 4.0: DONE ---------------------------------------- Data objects with at least one member are currently automatically frozen on construction, and shareable if all members are shareable. However, a Data object with no members is not frozen on construction. I would expect such an object similarly to be frozen (and also shareable since it has no non-shareable members). ``` Foo = Data.define(:foo) Foo.new(1).frozen? # => true Bar = Data.define Bar.new.frozen? # => false ``` -- https://bugs.ruby-lang.org/
participants (4)
-
dazuma (Daniel Azuma) -
hsbt (Hiroshi SHIBATA) -
k0kubun (Takashi Kokubun) -
nagachika (Tomoyuki Chikanaga)