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

ruby-changes:17560

From: yugui <ko1@a...>
Date: Sat, 23 Oct 2010 18:37:22 +0900 (JST)
Subject: [ruby-changes:17560] Ruby:r29565 (ruby_1_9_2): merges r29318 from trunk into ruby_1_9_2.

yugui	2010-10-23 18:37:01 +0900 (Sat, 23 Oct 2010)

  New Revision: 29565

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

  Log:
    merges r29318 from trunk into ruby_1_9_2.
    --
    * vm_insnhelper.c (vm_cref_push): no outer cref is needed for proc
      from method.  Bug #3786, Bug #3860, [ruby-core:32501]

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/test/ruby/test_eval.rb
    branches/ruby_1_9_2/version.h
    branches/ruby_1_9_2/vm_insnhelper.c

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 29564)
+++ ruby_1_9_2/ChangeLog	(revision 29565)
@@ -1,3 +1,8 @@
+Thu Sep 23 09:01:28 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_insnhelper.c (vm_cref_push): no outer cref is needed for proc
+	  from method.  Bug #3786, Bug #3860, [ruby-core:32501]
+
 Wed Oct  6 11:52:12 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* io.c (fptr_finalize): write_mutex might have been destroyed
Index: ruby_1_9_2/version.h
===================================================================
--- ruby_1_9_2/version.h	(revision 29564)
+++ ruby_1_9_2/version.h	(revision 29565)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 18
+#define RUBY_PATCHLEVEL 19
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1
Index: ruby_1_9_2/vm_insnhelper.c
===================================================================
--- ruby_1_9_2/vm_insnhelper.c	(revision 29564)
+++ ruby_1_9_2/vm_insnhelper.c	(revision 29565)
@@ -1053,22 +1053,24 @@
 }
 
 static NODE *
-vm_get_cref(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
+vm_get_cref0(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
 {
-    NODE *cref = 0;
-
     while (1) {
 	if (lfp == dfp) {
-	    cref = iseq->cref_stack;
-	    break;
+	    return iseq->cref_stack;
 	}
 	else if (dfp[-1] != Qnil) {
-	    cref = (NODE *)dfp[-1];
-	    break;
+	    return (NODE *)dfp[-1];
 	}
 	dfp = GET_PREV_DFP(dfp);
     }
+}
 
+static NODE *
+vm_get_cref(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
+{
+    NODE *cref = vm_get_cref0(iseq, lfp, dfp);
+
     if (cref == 0) {
 	rb_bug("vm_get_cref: unreachable");
     }
@@ -1084,10 +1086,10 @@
     cref->nd_visi = noex;
 
     if (blockptr) {
-	cref->nd_next = vm_get_cref(blockptr->iseq, blockptr->lfp, blockptr->dfp);
+	cref->nd_next = vm_get_cref0(blockptr->iseq, blockptr->lfp, blockptr->dfp);
     }
     else if (cfp) {
-	cref->nd_next = vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp);
+	cref->nd_next = vm_get_cref0(cfp->iseq, cfp->lfp, cfp->dfp);
     }
 
     return cref;
Index: ruby_1_9_2/test/ruby/test_eval.rb
===================================================================
--- ruby_1_9_2/test/ruby/test_eval.rb	(revision 29564)
+++ ruby_1_9_2/test/ruby/test_eval.rb	(revision 29565)
@@ -415,4 +415,19 @@
     assert_raise(ArgumentError) {eval("__ENCODING__".encode("utf-32be"))}
     assert_raise(ArgumentError) {eval("__ENCODING__".encode("utf-32le"))}
   end
+
+  def test_instance_eval_method_proc
+    bug3860 = Class.new do
+      def initialize(a);
+        @a=a
+      end
+      def get(*args)
+        @a
+      end
+    end
+    foo = bug3860.new 1
+    foo_pr = foo.method(:get).to_proc
+    result = foo.instance_eval(&foo_pr)
+    assert_equal(1, result, 'Bug #3786, Bug #3860, [ruby-core:32501]')
+  end
 end

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

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