Project

General

Profile

Bug #15572

`RubyVM::InstructionSequence` doesn't work with `extend`.

Added by ioquatix (Samuel Williams) 3 months ago. Updated 3 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:91323]

Description

For some reason,RubyVM::InstructionSequence.extend doesn't seem to work as expected.

module Loader
  def load_iseq(path)
    puts path
    return compile_file(path)
  end
end

# This doesn't work?
# RubyVM::InstructionSequence.extend(Loader)

# This works:
class << RubyVM::InstructionSequence
  prepend Loader
end

History

Updated by wanabe (_ wanabe) 3 months ago

ioquatix (Samuel Williams) wrote:

For some reason,RubyVM::InstructionSequence.extend doesn'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.

Also available in: Atom PDF