Project

General

Profile

Actions

Bug #14619

closed

method(m) is not invoking respond_to_missing?

Added by dblock (Daniel Doubrovkine) about 6 years ago. Updated about 6 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
[ruby-core:86207]

Description

class VariantHash < Hash
  def respond_to_missing?(method_name, *args)
    true
  end

  def method_missing(method_name, *args, &blk)
    42
  end
end


m = "foo_"
h = VariantHash.new(m => 'a')
puts h.method(m)
puts h.send(m)

Ruby 2.2.2

t.rb:14:in `method': undefined method `foo_' for class `VariantHash' (NameError)
	from t.rb:14:in `<main>'

All other versions of Ruby, including 2.4.1

#<Method: VariantHash#foo_>
42

I couldn't find a dup for this, trying to track down whether this was a known bug. Thank you and sorry if this is a dup. I'm coming from https://github.com/intridea/hashie/pull/443

Updated by dblock (Daniel Doubrovkine) about 6 years ago

Possibly a regression from a fix that was made for https://bugs.ruby-lang.org/issues/10985?

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

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

It works in ruby 2.2.9.

Updated by dblock (Daniel Doubrovkine) about 6 years ago

Thanks nobu, indeed, I just wanted to make sure this is seen for a possible p9? patch for 2.2.2, feel free to close if this doesn't need to be backported.

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

It has been backported to 2.2 and released already.
As we don't release branch-from-branch, "patch for 2.2.2" doesn't make sense.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0