Project

General

Profile

Actions

Bug #22505

open

UnboundMethod#{bind,bind_call} results in incorrect behavior when method owner is at multiple places in ancestry

Bug #22505: UnboundMethod#{bind,bind_call} results in incorrect behavior when method owner is at multiple places in ancestry

Added by jeremyevans0 (Jeremy Evans) 3 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:127326]

Description

If a method owner is at multiple places in the ancestry, UnboundMethod#bind can result in incorrect behavior, making an UnboundMethod from a superclass method bind to a method defined in a subclass:

module M
  def m = [:m, *super]
end
class C
  prepend M
  def m = [:c]
end
class SC < C
  prepend M
  def m = [:sc, *super]
end

C.instance_method(:m).bind_call(SC.new)
# => [:m, :sc, :m, :c]
# Should be: [:m, :c]

This was originally discovered while working on #22462, but it's unrelated to method equality.

The incorrect behavior appears to have started in Ruby 2.3, as Ruby 2.0-2.2 give the expected result.

I've submitted a PR to fix this issue: https://github.com/ruby/ruby/pull/19695

No data to display

Actions

Also available in: PDF Atom