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

ruby-changes:31847

From: nobu <ko1@a...>
Date: Sat, 30 Nov 2013 13:21:27 +0900 (JST)
Subject: [ruby-changes:31847] nobu:r43926 (trunk): range.c: revert the old behavior

nobu	2013-11-30 13:21:22 +0900 (Sat, 30 Nov 2013)

  New Revision: 43926

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

  Log:
    range.c: revert the old behavior
    
    * range.c (range_each): revert the old behavior, no block is given to
      the yielded block.

  Modified files:
    trunk/range.c
    trunk/test/ruby/test_range.rb
Index: range.c
===================================================================
--- range.c	(revision 43925)
+++ range.c	(revision 43926)
@@ -796,7 +796,7 @@ range_each(VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L796
 
 	    args[0] = end;
 	    args[1] = EXCL(range) ? Qtrue : Qfalse;
-	    rb_block_call(tmp, rb_intern("upto"), 2, args, rb_yield_block, 0);
+	    rb_block_call(tmp, rb_intern("upto"), 2, args, each_i, 0);
 	}
 	else {
 	    if (!discrete_object_p(beg)) {
Index: test/ruby/test_range.rb
===================================================================
--- test/ruby/test_range.rb	(revision 43925)
+++ test/ruby/test_range.rb	(revision 43926)
@@ -558,4 +558,12 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_range.rb#L558
       assert_equal(42, answer, msg)
     }
   end
+
+  def test_each_no_blockarg
+    a = "a"
+    def a.upto(x, e, &b)
+      super {|y| b.call(y) {|z| assert(false)}}
+    end
+    (a.."c").each {|x, &b| assert_nil(b)}
+  end
 end

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

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