Project

General

Profile

Bug #10985

Ruby 2.2 respond_to_missing?/method_missing/Object#method is not detecting properly

Added by michaelherold (Michael Herold) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:<unknown>]

Description

I'm one of the maintainers of the hashie gem. We had some reports that one of our specs started failing with Ruby 2.2 (and it was failing in ruby-head before then, but no one noticed), where Object#method was not picking up a respond_to_missing?/method_missing combo for our dynamic setters. This only occurs when we are dynamically constructing the method name from a string.

I have isolated the issue out into a tiny sample project that shows the issue. You can see that sample on Github. That repository is set up to have Travis run on Ruby 2.1.5, 2.2.0, 2.2.1, and ruby-head to show that the issue is introduced in the 2.2 line.

I'm having trouble isolating the issue down at the C level, but from a Ruby level, it seems that dynamically constructed symbols aren't the same as explicitly constructed (i.e. fully typed out) symbols. Using the syntax from my little test repository:

widget = Widget.new

widget.method(:abc=)  #=> This is found
widget.method("abc=") #=> This is found because it has previously been accessed via a symbol

widget.method("xyz=") #=> This is NOT found
widget.method(:xyz=)  #=> This is found
widget.method("xyz=") #=> Now this is found because it was previously accessed via a symbol

Because of that behavior, it makes me think that something is happening with the conversion of the argument to a symbol, but that could be way off.

Please let me know if the explanation is vague. I'm happy to provide any more information that you would find helpful.

Associated revisions

Revision c8a28a5a
Added by nobu (Nobuyoshi Nakada) about 4 years ago

proc.c: respond_to_missing? at Method

  • proc.c (respond_to_missing_p): check if the receiver responds to the given method by respond_to_missing?.
  • proc.c (mnew_missing): create Method object for method_missing. [ruby-core:68564] [Bug #10985]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50038
Added by nobu (Nobuyoshi Nakada) about 4 years ago

proc.c: respond_to_missing? at Method

  • proc.c (respond_to_missing_p): check if the receiver responds to the given method by respond_to_missing?.
  • proc.c (mnew_missing): create Method object for method_missing. [ruby-core:68564] [Bug #10985]

Revision 50038
Added by nobu (Nobuyoshi Nakada) about 4 years ago

proc.c: respond_to_missing? at Method

  • proc.c (respond_to_missing_p): check if the receiver responds to the given method by respond_to_missing?.
  • proc.c (mnew_missing): create Method object for method_missing. [ruby-core:68564] [Bug #10985]

Revision 50038
Added by nobu (Nobuyoshi Nakada) about 4 years ago

proc.c: respond_to_missing? at Method

  • proc.c (respond_to_missing_p): check if the receiver responds to the given method by respond_to_missing?.
  • proc.c (mnew_missing): create Method object for method_missing. [ruby-core:68564] [Bug #10985]

Revision 50038
Added by nobu (Nobuyoshi Nakada) about 4 years ago

proc.c: respond_to_missing? at Method

  • proc.c (respond_to_missing_p): check if the receiver responds to the given method by respond_to_missing?.
  • proc.c (mnew_missing): create Method object for method_missing. [ruby-core:68564] [Bug #10985]

Revision 50038
Added by nobu (Nobuyoshi Nakada) about 4 years ago

proc.c: respond_to_missing? at Method

  • proc.c (respond_to_missing_p): check if the receiver responds to the given method by respond_to_missing?.
  • proc.c (mnew_missing): create Method object for method_missing. [ruby-core:68564] [Bug #10985]

Revision b836c3ac
Added by nagachika (Tomoyuki Chikanaga) about 4 years ago

merge revision(s) 50038: [Backport #10985]

    * proc.c (respond_to_missing_p): check if the receiver responds to
      the given method by respond_to_missing?.

    * proc.c (mnew_missing): create Method object for method_missing.
      [ruby-core:68564] [Bug #10985]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50546
Added by nagachika (Tomoyuki Chikanaga) about 4 years ago

merge revision(s) 50038: [Backport #10985]

* proc.c (respond_to_missing_p): check if the receiver responds to
  the given method by respond_to_missing?.

* proc.c (mnew_missing): create Method object for method_missing.
  [ruby-core:68564] [Bug #10985]

History

#1

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r50038.


proc.c: respond_to_missing? at Method

  • proc.c (respond_to_missing_p): check if the receiver responds to the given method by respond_to_missing?.
  • proc.c (mnew_missing): create Method object for method_missing. [ruby-core:68564] [Bug #10985]
#2

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Status changed from Closed to Open
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED
#3

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Status changed from Open to Closed
#4

Updated by michaelherold (Michael Herold) about 4 years ago

Thank you for the fix and the swift turnaround, Nakada-san! I'm looking forward to the backport.

#5

Updated by nagachika (Tomoyuki Chikanaga) about 4 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

Backported into ruby_2_2 branch at r50546.

Also available in: Atom PDF