Project

General

Profile

Bug #12164

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

I tried to bind method from Object to BasicObject and I suddenly succeeded.
For example:

```

$ `$ irb
2.3.0 :001 > BasicObject.send :define_method, :methods, Object.instance_method(:methods)
=> :methods
2.3.0 :002 > BasicObject.new.methods
=> [:!, :==, :!=, :__send__, :equal?, :methods, :instance_eval, :instance_exec, :__id__]
2.3.0 :003 >
``` `

In earlier ruby versions such code would raise an exception:

```

`
$ irb
2.2.4 :001 > BasicObject.send :define_method, :methods, Object.instance_method(:methods)
TypeError: bind argument must be a subclass of Object
from (irb):1:in `define_method'
from (irb):1
from /Users/gordon/.rvm/rubies/ruby-2.2.4/bin/irb:11:in `<main>'
2.2.4 :002 >
``` `

Is it a bug or a feature?
Probably it is somehow related to https://bugs.ruby-lang.org/issues/11278

Back