Project

General

Profile

Actions

Bug #21440

closed

Cannot create instances of frozen Data subclasses

Added by jeremyevans0 (Jeremy Evans) about 23 hours ago. Updated about 20 hours ago.

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

Description

This fails since Data was added in Ruby 3.2:

Class.new(Data.define(:a)).freeze.new
# can't modify frozen #<Class:#<Class:0x000079cf41253160>>: #<Class:0x000079cf41253160> (FrozenError)

Note that the error occurs even before the ArgumentError due to the missing argument to new.

This doesn't happen on classes created with Data.define (only subclasses of those classes):

Data.define(:a).freeze.new
# missing keyword: :a (ArgumentError)

Updated by nobu (Nobuyoshi Nakada) about 21 hours ago

Also Class.new(Struct.new(:a)).freeze.new.

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 20 hours ago

  • Status changed from Open to Closed

Applied in changeset git|2e7e78cd590d20aa9d41422e96302f3edd73f623.


[Bug #21440] Stop caching member list in frozen Data/Struct class

Actions

Also available in: Atom PDF

Like0
Like0Like0