The method introduced by mruby#5979 causes a fault by swapping classes. ```console % bin/mruby -e 'Method = Proc; p Object.method(:inspect)' zsh: segmentation fault (core dumped) bin/mruby -e 'Method = Proc; p Object.method(:inspect)' ``` After applying this patch, a `TypeError` exception will be raised. ```console % bin/mruby -e 'Method = Proc; p Object.method(:inspect)' trace (most recent call last): [1] -e:1 -e:1:in method: allocation failure of Proc (TypeError) ``` However, if the `mrb_vtype` is the same object, the same care must still be taken as before. ```console % bin/mruby -e 'Method = Binding; p method(:puts).eval("12345")' trace (most recent call last): [1] -e:1 -e:1:in eval: wrong argument type nil (expected Proc) (TypeError) ```
dearblue added a commit to dearblue/mruby that referenced this pull request
Dec 23, 2023If `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.
Merged