ruby-changes:22567
From: nobu <ko1@a...>
Date: Wed, 15 Feb 2012 10:34:08 +0900 (JST)
Subject: [ruby-changes:22567] nobu:r34616 (ruby_1_9_3): merge revision(s) r34564:
nobu 2012-02-15 10:33:56 +0900 (Wed, 15 Feb 2012) New Revision: 34616 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34616 Log: merge revision(s) r34564: * vm_eval.c (check_funcall): Call respond_to? with matching arity for legacy single-argument implementations. [ruby-trunk - Bug #6000] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/test/ruby/test_object.rb branches/ruby_1_9_3/version.h branches/ruby_1_9_3/vm_eval.c Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 34615) +++ ruby_1_9_3/ChangeLog (revision 34616) @@ -1,3 +1,8 @@ +Wed Feb 15 10:33:41 2012 Eric Hodel <drbrain@s...> + + * vm_eval.c (check_funcall): Call respond_to? with matching arity for + legacy single-argument implementations. [ruby-trunk - Bug #6000] + Wed Feb 15 10:25:22 2012 Naohisa Goto <ngotogenome@g...> * vm_eval.c (check_funcall): set array elements one-by-one to fix Index: ruby_1_9_3/vm_eval.c =================================================================== --- ruby_1_9_3/vm_eval.c (revision 34615) +++ ruby_1_9_3/vm_eval.c (revision 34616) @@ -274,10 +274,13 @@ 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; } } Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 34615) +++ ruby_1_9_3/version.h (revision 34616) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 118 +#define RUBY_PATCHLEVEL 119 #define RUBY_RELEASE_DATE "2012-02-15" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/test/ruby/test_object.rb =================================================================== --- ruby_1_9_3/test/ruby/test_object.rb (revision 34615) +++ ruby_1_9_3/test/ruby/test_object.rb (revision 34616) @@ -420,6 +420,20 @@ 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]' -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/