Skip to content

Inherit MRB_FL_UNDEF_ALLOCATE in subclasses#6123

Merged
matz merged 1 commit intomruby:masterfrom
dearblue:allocate-undef.2
Dec 27, 2023
Merged

Inherit MRB_FL_UNDEF_ALLOCATE in subclasses#6123
matz merged 1 commit intomruby:masterfrom
dearblue:allocate-undef.2

Conversation

@dearblue
Copy link
Contributor

If Class#allocate is prohibited, subclasses should also be implicitly prohibited.

p Class.new(Struct).allocate.class
# => #<Class:0x82362ac00>                                             by #6122
# => allocator undefined for #<Class:0x000000083a983220> (TypeError)  by Ruby 3.2

Added MRB_DEFINE_ALLOCATOR() to allow subclasses to use Class#allocate.

Supplement to #6122.

If `Class#allocate` is prohibited, subclasses should also be implicitly prohibited.

```ruby
p Class.new(Struct).allocate.class
# => #<Class:0x82362ac00>                                             by mruby#6122
# => allocator undefined for #<Class:0x000000083a983220> (TypeError)  by Ruby 3.2
```

Added `MRB_DEFINE_ALLOCATOR()` to allow subclasses to use `Class#allocate`.

Supplement to mruby#6122.
@dearblue dearblue requested a review from matz as a code owner December 23, 2023 12:12
@matz matz merged commit dc633ec into mruby:master Dec 27, 2023
@dearblue dearblue deleted the allocate-undef.2 branch January 3, 2024 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants