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

ruby-changes:39955

From: nobu <ko1@a...>
Date: Mon, 5 Oct 2015 15:35:06 +0900 (JST)
Subject: [ruby-changes:39955] nobu:r52036 (trunk): proc.c: set ep properly

nobu	2015-10-05 15:34:58 +0900 (Mon, 05 Oct 2015)

  New Revision: 52036

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

  Log:
    proc.c: set ep properly
    
    * proc.c (proc_new): link ep to calling block.
      [ruby-core:70980] [Bug #11566]

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
    trunk/test/ruby/test_symbol.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52035)
+++ ChangeLog	(revision 52036)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Oct  5 15:34:56 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* proc.c (proc_new): link ep to calling block.
+	  [ruby-core:70980] [Bug #11566]
+
 Mon Oct  5 00:53:51 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* dir.c (rb_dir_getwd): make ASCII-8BIT if filesystem encoding is
Index: proc.c
===================================================================
--- proc.c	(revision 52035)
+++ proc.c	(revision 52036)
@@ -601,6 +601,7 @@ proc_new(VALUE klass, int8_t is_lambda) https://github.com/ruby/ruby/blob/trunk/proc.c#L601
 	if (RUBY_VM_IFUNC_P(procval)) {
 	    VALUE newprocval = rb_proc_alloc(klass);
 	    rb_proc_t *proc = RTYPEDDATA_DATA(newprocval);
+	    proc->block = *block;
 	    proc->block.iseq = (rb_iseq_t *)procval;
 	    proc->block.proc = newprocval;
 	    return newprocval;
Index: test/ruby/test_symbol.rb
===================================================================
--- test/ruby/test_symbol.rb	(revision 52035)
+++ test/ruby/test_symbol.rb	(revision 52036)
@@ -117,18 +117,29 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L117
       ary_ids = ary.collect{|x| x.object_id }
       assert_equal ary_ids, ary.collect(&:object_id)
     end
+  end
 
+  def test_to_proc_yield
     assert_ruby_status([], <<-"end;", timeout: 5.0)
       GC.stress = true
       true.tap(&:itself)
     end;
+  end
 
+  def test_to_proc_new_proc
     assert_ruby_status([], <<-"end;", timeout: 5.0)
       GC.stress = true
       2.times {Proc.new(&:itself)}
     end;
   end
 
+  def test_to_proc_no_method
+    assert_separately([], <<-"end;", timeout: 5.0)
+      bug11566 = '[ruby-core:70980] [Bug #11566]'
+      assert_raise(NoMethodError, bug11566) {Proc.new(&:foo).(1)}
+    end;
+  end
+
   def test_call
     o = Object.new
     def o.foo(x, y); x + y; end

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

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