to_ary not respecting respond_to?
@p = Object.new
raise "I should never be called"
p :bad_respond_to? => a
def method_missing(msg, *)
p :bad_method_missing => msg
Exception `RuntimeError' at wtf.rb:6 - I should never be called¶
wtf.rb:6:in `to_ary': I should never be called (RuntimeError)¶
from wtf.rb:17:in `method_missing'¶
from wtf.rb:21:in `flatten'¶
from wtf.rb:21:in `'¶
Updated by nobu (Nobuyoshi Nakada) about 9 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r32855.
Ryan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- vm_eval.c (check_funcall): try respond_to? first if redefined. [Bug #5158]
Updated by aprescott (Adam Prescott) about 9 years ago
On Thu, Aug 4, 2011 at 11:37 PM, Ryan Davis firstname.lastname@example.org:
Someone made a comment on that post linking to
explains, specifically for Array#flatten:
In Ruby 1.8, the process is essentially the following:
In Ruby 1.9, it was changed to:
I'm not sure why that changed happened, but at least that seems to be the
source of the behaviour.
Updated by Anonymous about 9 years ago
On Aug 5, 2011, at 6:06 AM, Adam Prescott wrote:
I'm not sure why that changed happened, but at least that seems to be the source of the behaviour.
I believe it happened because respond_to? is unreliable in the presence of
method_missing unless a lot of care is taken, and that care is rarely taken.