ruby-changes:22566
From: nobu <ko1@a...>
Date: Wed, 15 Feb 2012 10:29:43 +0900 (JST)
Subject: [ruby-changes:22566] nobu:r34615 (ruby_1_9_3): merge revision(s) r32855,r32857,r33493,r34554:
nobu 2012-02-15 10:29:34 +0900 (Wed, 15 Feb 2012) New Revision: 34615 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34615 Log: merge revision(s) r32855,r32857,r33493,r34554: * vm_eval.c (check_funcall): try respond_to? first if redefined. [Bug #5158] * test/ruby/test_object.rb: tests that respond_to? returns false. * vm_eval.c (check_funcall): set array elements one-by-one to fix compile error with Fujitsu C Compiler 5.6 on Solaris 10 on Sparc. Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/test/ruby/test_object.rb branches/ruby_1_9_3/test/ruby/test_proc.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 34614) +++ ruby_1_9_3/ChangeLog (revision 34615) @@ -1,3 +1,17 @@ +Wed Feb 15 10:25:22 2012 Naohisa Goto <ngotogenome@g...> + + * vm_eval.c (check_funcall): set array elements one-by-one to fix + compile error with Fujitsu C Compiler 5.6 on Solaris 10 on Sparc. + +Wed Feb 15 10:25:22 2012 Nobuyoshi Nakada <nobu@r...> + + * test/ruby/test_object.rb: tests that respond_to? returns false. + +Wed Feb 15 10:25:22 2012 Nobuyoshi Nakada <nobu@r...> + + * vm_eval.c (check_funcall): try respond_to? first if redefined. + [Bug #5158] + Wed Feb 15 07:15:50 2012 Nobuyoshi Nakada <nobu@r...> * compile.c (defined_expr): guard the whole expression. Index: ruby_1_9_3/vm_eval.c =================================================================== --- ruby_1_9_3/vm_eval.c (revision 34614) +++ ruby_1_9_3/vm_eval.c (revision 34615) @@ -204,7 +204,7 @@ } static inline rb_method_entry_t *rb_search_method_entry(VALUE recv, ID mid); -static inline int rb_method_call_status(rb_thread_t *th, rb_method_entry_t *me, call_type scope, VALUE self); +static inline int rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self); #define NOEX_OK NOEX_NOSUPER /*! @@ -266,12 +266,26 @@ static VALUE check_funcall(VALUE recv, ID mid, int argc, VALUE *argv) { - rb_method_entry_t *me = rb_search_method_entry(recv, mid); + VALUE klass = CLASS_OF(recv); + const rb_method_entry_t *me; rb_thread_t *th = GET_THREAD(); - int call_status = rb_method_call_status(th, me, CALL_FCALL, Qundef); + int call_status; + me = rb_method_entry(klass, idRespond_to); + if (me && !(me->flag & NOEX_BASIC)) { + VALUE args[2]; + + args[0] = ID2SYM(mid); + args[1] = Qtrue; + if (!RTEST(vm_call0(th, recv, idRespond_to, 2, args, me))) { + return Qundef; + } + } + + me = rb_search_method_entry(recv, mid); + call_status = rb_method_call_status(th, me, CALL_FCALL, Qundef); if (call_status != NOEX_OK) { - if (rb_method_basic_definition_p(CLASS_OF(recv), idMethodMissing)) { + if (rb_method_basic_definition_p(klass, idMethodMissing)) { return Qundef; } else { @@ -376,7 +390,7 @@ } static inline int -rb_method_call_status(rb_thread_t *th, rb_method_entry_t *me, call_type scope, VALUE self) +rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self) { VALUE klass; ID oid; Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 34614) +++ ruby_1_9_3/version.h (revision 34615) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 117 +#define RUBY_PATCHLEVEL 118 #define RUBY_RELEASE_DATE "2012-02-15" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/test/ruby/test_proc.rb =================================================================== --- ruby_1_9_3/test/ruby/test_proc.rb (revision 34614) +++ ruby_1_9_3/test/ruby/test_proc.rb (revision 34615) @@ -787,7 +787,7 @@ end def test_splat_without_respond_to - def (obj = Object.new).respond_to?(m); false end + def (obj = Object.new).respond_to?(m,*); false end [obj].each do |a, b| assert_equal([obj, nil], [a, b], '[ruby-core:24139]') end Index: ruby_1_9_3/test/ruby/test_object.rb =================================================================== --- ruby_1_9_3/test/ruby/test_object.rb (revision 34614) +++ ruby_1_9_3/test/ruby/test_object.rb (revision 34615) @@ -181,18 +181,30 @@ o = Object.new def o.to_s; 1; end assert_raise(TypeError) { String(o) } + def o.to_s; "o"; end + assert_equal("o", String(o)) + def o.respond_to?(*) false; end + assert_raise(TypeError) { String(o) } end def test_check_convert_type o = Object.new def o.to_a; 1; end assert_raise(TypeError) { Array(o) } + def o.to_a; [1]; end + assert_equal([1], Array(o)) + def o.respond_to?(*) false; end + assert_equal([o], Array(o)) end def test_to_integer o = Object.new def o.to_i; nil; end assert_raise(TypeError) { Integer(o) } + def o.to_i; 42; end + assert_equal(42, Integer(o)) + def o.respond_to?(*) false; end + assert_raise(TypeError) { Integer(o) } end class MyInteger @@ -383,6 +395,31 @@ end end + def test_implicit_respond_to + bug5158 = '[ruby-core:38799]' + + p = Object.new + + called = [] + p.singleton_class.class_eval do + define_method(:to_ary) do + called << [:to_ary, bug5158] + end + end + [[p]].flatten + assert_equal([[:to_ary, bug5158]], called, bug5158) + + 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, true]], called, bug5158) + end + def test_method_missing_passed_block bug5731 = '[ruby-dev:44961]' -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/