Project

General

Profile

Actions

Bug #12164

closed

Binding UnboundMethod to BasicObject

Bug #12164: Binding UnboundMethod to BasicObject

Added by decuplet (Nikita Shilnikov) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
[ruby-core:74265]

Description

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


Related issues 1 (0 open1 closed)

Updated by nobu (Nobuyoshi Nakada) over 9 years ago Actions #1 [ruby-core:74266]

  • Description updated (diff)
  • Status changed from Open to Closed

Yes.

Updated by decuplet (Nikita Shilnikov) over 9 years ago Actions #2 [ruby-core:74267]

Nobuyoshi Nakada wrote:

Yes.

Thank you! Well... a feature?

Updated by nobu (Nobuyoshi Nakada) over 9 years ago Actions #3 [ruby-core:74274]

"Yes" was to

Probably it is somehow related to https://bugs.ruby-lang.org/issues/11278

I guess it's a bug-fix, but maybe an improvement.
Subtle.

Updated by usa (Usaku NAKAMURA) over 9 years ago Actions #4

  • Related to Bug #11278: remove rb_control_frame_t::klass added
Actions

Also available in: PDF Atom