Project

General

Profile

Backport #6000 ยป vm_eval.c.respond_to_arity.patch

drbrain (Eric Hodel), 02/11/2012 09:02 AM

View differences:

vm_eval.c (working copy)
me = rb_method_entry(klass, idRespond_to);
if (me && !(me->flag & NOEX_BASIC)) {
VALUE args[2];
int arity = rb_method_entry_arity(me);
if (arity < 1 || arity > 3) arity = 2;
args[0] = ID2SYM(mid);
args[1] = Qtrue;
if (!RTEST(vm_call0(th, recv, idRespond_to, 2, args, me))) {
if (!RTEST(vm_call0(th, recv, idRespond_to, arity, args, me))) {
return Qundef;
}
}
test/ruby/test_object.rb (working copy)
assert_equal([[:respond_to?, :to_ary, true]], called, bug5158)
end
def test_implicit_respond_to_arity_1
p = Object.new
called = []
p.singleton_class.class_eval do
define_method(:respond_to?) do |a|
called << [:respond_to?, a]
false
end
end
[[p]].flatten
assert_equal([[:respond_to?, :to_ary]], called, '[bug:6000]')
end
def test_method_missing_passed_block
bug5731 = '[ruby-dev:44961]'
    (1-1/1)