Actions
Bug #15572
closed`RubyVM::InstructionSequence` doesn't work with `extend`.
Bug #15572:
`RubyVM::InstructionSequence` doesn't work with `extend`.
Description
Actions
Added by ioquatix (Samuel Williams) over 7 years ago. Updated over 7 years ago.
Description
ioquatix (Samuel Williams) wrote:
For some reason,
RubyVM::InstructionSequence.extenddoesn't seem to work as expected.
Kernel#extend seems to work fine.
$ ./miniruby -ve 'module Foo; def foo; p :foo; end; end; RubyVM::InstructionSequence.extend(Foo); RubyVM::InstructionSequence.foo'
ruby 2.7.0dev (2019-01-30 trunk 66946) [x86_64-linux]
:foo
The script of [ruby-core:91323] uses method name "load_iseq" that is marked as "UNDEF". see r55656.
So I guess it is expected behavior, but I don't know the reason.
As wanabe pointed out, this isn't a bug. load_iseq is undef in the singleton class, which occurs before extended modules during method lookup. prepend on the singleton class works because prepended modules on the singleton class occur before methods in the singleton class itself during method lookup. Calling super in the prepended method results in a NoMethodError.