[前][次][番号順一覧][スレッド一覧]

ruby-changes:22401

From: kosaki <ko1@a...>
Date: Tue, 7 Feb 2012 05:08:29 +0900 (JST)
Subject: [ruby-changes:22401] kosaki:r34450 (ruby_1_9_3): merge revision(s) r34399:

kosaki	2012-02-07 05:03:14 +0900 (Tue, 07 Feb 2012)

  New Revision: 34450

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34450

  Log:
    merge revision(s) r34399:
    
    * vm_eval.c (vm_call0): should pass block to enumerators.  patched
      by Kazuki Tsujimoto.  [ruby-dev:44961][Bug #5731]
    
    * vm_eval.c (method_missing), vm_insnhelper.c (vm_call_method):
      ditto.  patched by satoshi shiba.

  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
    branches/ruby_1_9_3/vm_insnhelper.c

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 34449)
+++ ruby_1_9_3/ChangeLog	(revision 34450)
@@ -1,3 +1,11 @@
+Mon Feb  6 15:01:55 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_eval.c (vm_call0): should pass block to enumerators.  patched
+	  by Kazuki Tsujimoto.  [ruby-dev:44961][Bug #5731]
+
+	* vm_eval.c (method_missing), vm_insnhelper.c (vm_call_method):
+	  ditto.  patched by satoshi shiba.
+
 Mon Feb  6 21:52:20 2012  Yuki Sonoda (Yugui)  <yugui@y...>
 
 	* common.mk (INSTRUBY_ARGS): added --mantype to apply mdoc2man.rb
Index: ruby_1_9_3/vm_eval.c
===================================================================
--- ruby_1_9_3/vm_eval.c	(revision 34449)
+++ ruby_1_9_3/vm_eval.c	(revision 34450)
@@ -118,6 +118,7 @@
 
 	RB_GC_GUARD(new_args);
 	rb_ary_unshift(new_args, ID2SYM(id));
+	th->passed_block = blockptr;
 	return rb_funcall2(recv, idMethodMissing,
 			   argc+1, RARRAY_PTR(new_args));
       }
@@ -547,6 +548,7 @@
 {
     VALUE *nargv, result, argv_ary = 0;
     rb_thread_t *th = GET_THREAD();
+    const rb_block_t *blockptr = th->passed_block;
 
     th->method_missing_reason = call_status;
     th->passed_block = 0;
@@ -572,6 +574,7 @@
     if (rb_method_basic_definition_p(CLASS_OF(obj) , idMethodMissing)) {
 	raise_method_missing(th, argc+1, nargv, obj, call_status | NOEX_MISSING);
     }
+    th->passed_block = blockptr;
     result = rb_funcall2(obj, idMethodMissing, argc + 1, nargv);
     if (argv_ary) rb_ary_clear(argv_ary);
     return result;
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 34449)
+++ ruby_1_9_3/version.h	(revision 34450)
@@ -1,10 +1,10 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 43
+#define RUBY_PATCHLEVEL 44
 
-#define RUBY_RELEASE_DATE "2012-02-06"
+#define RUBY_RELEASE_DATE "2012-02-07"
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 6
+#define RUBY_RELEASE_DAY 7
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/vm_insnhelper.c
===================================================================
--- ruby_1_9_3/vm_insnhelper.c	(revision 34449)
+++ ruby_1_9_3/vm_insnhelper.c	(revision 34450)
@@ -555,6 +555,7 @@
 		argv[0] = ID2SYM(me->def->original_id);
 		MEMCPY(argv+1, cfp->sp - num, VALUE, num);
 		cfp->sp += - num - 1;
+		th->passed_block = blockptr;
 		val = rb_funcall2(recv, rb_intern("method_missing"), num+1, argv);
 		break;
 	      }
Index: ruby_1_9_3/test/ruby/test_object.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_object.rb	(revision 34449)
+++ ruby_1_9_3/test/ruby/test_object.rb	(revision 34450)
@@ -383,6 +383,57 @@
     end
   end
 
+  def test_method_missing_passed_block
+    bug5731 = '[ruby-dev:44961]'
+
+    c = Class.new do
+      def method_missing(meth, *args) yield(meth, *args) end
+    end
+    a = c.new
+    result = nil
+    assert_nothing_raised(LocalJumpError, bug5731) do
+      a.foo {|x| result = x}
+    end
+    assert_equal(:foo, result, bug5731)
+    result = nil
+    e = a.enum_for(:foo)
+    assert_nothing_raised(LocalJumpError, bug5731) do
+      e.each {|x| result = x}
+    end
+    assert_equal(:foo, result, bug5731)
+
+    c = Class.new do
+      def respond_to_missing?(id, priv)
+        true
+      end
+      def method_missing(id, *args, &block)
+        return block.call(:foo, *args)
+      end
+    end
+    foo = c.new
+
+    result = nil
+    assert_nothing_raised(LocalJumpError, bug5731) do
+      foo.foobar {|x| result = x}
+    end
+    assert_equal(:foo, result, bug5731)
+    result = nil
+    assert_nothing_raised(LocalJumpError, bug5731) do
+      foo.enum_for(:foobar).each {|x| result = x}
+    end
+    assert_equal(:foo, result, bug5731)
+
+    result = nil
+    foobar = foo.method(:foobar)
+    foobar.call {|x| result = x}
+    assert_equal(:foo, result, bug5731)
+
+    result = nil
+    foobar = foo.method(:foobar)
+    foobar.enum_for(:call).each {|x| result = x}
+    assert_equal(:foo, result, bug5731)
+  end
+
   def test_send_with_no_arguments
     assert_raise(ArgumentError) { 1.send }
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]