mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
8ecfacefca
The method introduced by #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) ```
mruby-method
An implementation of class Method and UnboundMethod for mruby
p Enumerable.instance_method(:find_all).source_location
#=> ["mruby/mruby/mrblib/enum.rb", 148]
Note
You need to enable debug option in your build configuration to use
source_location method in this gem, for example:
MRuby::Build.new do |conf|
conf.enable_debug
end
Supported Methods
Kernel
Kernel#methodKernel#singleton_method
Module
Module#instance_method
Method class
Method#nameMethod#callMethod#super_methodMethod#arityMethod#unbindMethod#[]Method#ownerMethod#receiverMethod#parametersMethod#source_locationMethod#to_proc
UnboundMethod class
UnboundMethod#nameUnboundMethod#bindUnboundMethod#super_methodUnboundMethod#arityUnboundMethod#ownerUnboundMethod#parametersUnboundMethod#source_location