[ruby-core:91348] [Ruby trunk Bug#15572] `RubyVM::InstructionSequence` doesn't work with `extend`.

From: s.wanabe@...
Date: 2019-01-30 23:57:25 UTC
List: ruby-core #91348
Issue #15572 has been updated by wanabe (_ wanabe).


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.

----------------------------------------
Bug #15572: `RubyVM::InstructionSequence` doesn't work with `extend`.
https://bugs.ruby-lang.org/issues/15572#change-76598

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
For some reason,`RubyVM::InstructionSequence.extend` doesn't seem to work as expected.

```ruby
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
```




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next