% svn diff --diff-cmd diff -x '-u -p'
Index: NEWS
===================================================================
--- NEWS	(revision 49917)
+++ NEWS	(working copy)
@@ -25,6 +25,11 @@ with all sufficient information, see the
   * Array#flatten and Array#flatten! no longer try to call #to_ary
     method on elements beyond the given level.  [Bug #10748]
 
+* Enumerable
+  * Enumerable#chunk and Enumerable#slice_before no longer takes the
+    initial_state argument.
+    Use a local variable to maintain a state.
+
 * IO
   * IO#close doesn't raise when the IO object is closed.  [Feature #10718]
 
Index: enum.c
===================================================================
--- enum.c	(revision 49917)
+++ enum.c	(working copy)
@@ -2705,7 +2705,6 @@ enum_cycle(int argc, VALUE *argv, VALUE
 
 struct chunk_arg {
     VALUE categorize;
-    VALUE state;
     VALUE prev_value;
     VALUE prev_elts;
     VALUE yielder;
@@ -2721,10 +2720,7 @@ chunk_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, _
 
     ENUM_WANT_SVALUE();
 
-    if (NIL_P(argp->state))
-        v = rb_funcall(argp->categorize, id_call, 1, i);
-    else
-        v = rb_funcall(argp->categorize, id_call, 2, i, argp->state);
+    v = rb_funcall(argp->categorize, id_call, 1, i);
 
     if (v == alone) {
         if (!NIL_P(argp->prev_value)) {
@@ -2770,14 +2766,10 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yield
 
     enumerable = rb_ivar_get(enumerator, rb_intern("chunk_enumerable"));
     memo->categorize = rb_ivar_get(enumerator, rb_intern("chunk_categorize"));
-    memo->state = rb_ivar_get(enumerator, rb_intern("chunk_initial_state"));
     memo->prev_value = Qnil;
     memo->prev_elts = Qnil;
     memo->yielder = yielder;
 
-    if (!NIL_P(memo->state))
-	memo->state = rb_obj_dup(memo->state);
-
     rb_block_call(enumerable, id_each, 0, 0, chunk_ii, arg);
     memo = MEMO_FOR(struct chunk_arg, arg);
     if (!NIL_P(memo->prev_elts))
@@ -2788,7 +2780,6 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yield
 /*
  *  call-seq:
  *     enum.chunk { |elt| ... }                       -> an_enumerator
- *     enum.chunk(initial_state) { |elt, state| ... } -> an_enumerator (deprecated)
  *
  *  Enumerates over the items, chunking them together based on the return
  *  value of the block.
@@ -2874,22 +2865,16 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yield
  *
  */
 static VALUE
-enum_chunk(int argc, VALUE *argv, VALUE enumerable)
+enum_chunk(VALUE enumerable)
 {
-    VALUE initial_state;
     VALUE enumerator;
-    int n;
 
     if (!rb_block_given_p())
 	rb_raise(rb_eArgError, "no block given");
-    n = rb_scan_args(argc, argv, "01", &initial_state);
-    if (n != 0)
-        rb_warn("initial_state given for chunk.  (Use local variables.)");
 
     enumerator = rb_obj_alloc(rb_cEnumerator);
     rb_ivar_set(enumerator, rb_intern("chunk_enumerable"), enumerable);
     rb_ivar_set(enumerator, rb_intern("chunk_categorize"), rb_block_proc());
-    rb_ivar_set(enumerator, rb_intern("chunk_initial_state"), initial_state);
     rb_block_call(enumerator, idInitialize, 0, 0, chunk_i, enumerator);
     return enumerator;
 }
@@ -2898,7 +2883,6 @@ enum_chunk(int argc, VALUE *argv, VALUE
 struct slicebefore_arg {
     VALUE sep_pred;
     VALUE sep_pat;
-    VALUE state;
     VALUE prev_elts;
     VALUE yielder;
 };
@@ -2913,10 +2897,8 @@ slicebefore_ii(RB_BLOCK_CALL_FUNC_ARGLIS
 
     if (!NIL_P(argp->sep_pat))
         header_p = rb_funcall(argp->sep_pat, id_eqq, 1, i);
-    else if (NIL_P(argp->state))
-        header_p = rb_funcall(argp->sep_pred, id_call, 1, i);
     else
-        header_p = rb_funcall(argp->sep_pred, id_call, 2, i, argp->state);
+        header_p = rb_funcall(argp->sep_pred, id_call, 1, i);
     if (RTEST(header_p)) {
         if (!NIL_P(argp->prev_elts))
             rb_funcall(argp->yielder, id_lshift, 1, argp->prev_elts);
@@ -2942,13 +2924,9 @@ slicebefore_i(RB_BLOCK_CALL_FUNC_ARGLIST
     enumerable = rb_ivar_get(enumerator, rb_intern("slicebefore_enumerable"));
     memo->sep_pred = rb_attr_get(enumerator, rb_intern("slicebefore_sep_pred"));
     memo->sep_pat = NIL_P(memo->sep_pred) ? rb_ivar_get(enumerator, rb_intern("slicebefore_sep_pat")) : Qnil;
-    memo->state = rb_attr_get(enumerator, rb_intern("slicebefore_initial_state"));
     memo->prev_elts = Qnil;
     memo->yielder = yielder;
 
-    if (!NIL_P(memo->state))
-        memo->state = rb_obj_dup(memo->state);
-
     rb_block_call(enumerable, id_each, 0, 0, slicebefore_ii, arg);
     memo = MEMO_FOR(struct slicebefore_arg, arg);
     if (!NIL_P(memo->prev_elts))
@@ -2960,7 +2938,6 @@ slicebefore_i(RB_BLOCK_CALL_FUNC_ARGLIST
  *  call-seq:
  *     enum.slice_before(pattern)                             -> an_enumerator
  *     enum.slice_before { |elt| bool }                       -> an_enumerator
- *     enum.slice_before(initial_state) { |elt, state| bool } -> an_enumerator (deprecated)
  *
  *  Creates an enumerator for each chunked elements.
  *  The beginnings of chunks are defined by _pattern_ and the block.
@@ -3106,14 +3083,10 @@ enum_slice_before(int argc, VALUE *argv,
     VALUE enumerator;
 
     if (rb_block_given_p()) {
-        VALUE initial_state;
-        int n;
-        n = rb_scan_args(argc, argv, "01", &initial_state);
-        if (n != 0)
-	    rb_warn("initial_state given for slice_before.  (Use local variables.)");
+        if (argc != 0)
+            rb_error_arity(argc, 0, 0);
         enumerator = rb_obj_alloc(rb_cEnumerator);
         rb_ivar_set(enumerator, rb_intern("slicebefore_sep_pred"), rb_block_proc());
-        rb_ivar_set(enumerator, rb_intern("slicebefore_initial_state"), initial_state);
     }
     else {
         VALUE sep_pat;
@@ -3454,7 +3427,7 @@ Init_Enumerable(void)
     rb_define_method(rb_mEnumerable, "drop", enum_drop, 1);
     rb_define_method(rb_mEnumerable, "drop_while", enum_drop_while, 0);
     rb_define_method(rb_mEnumerable, "cycle", enum_cycle, -1);
-    rb_define_method(rb_mEnumerable, "chunk", enum_chunk, -1);
+    rb_define_method(rb_mEnumerable, "chunk", enum_chunk, 0);
     rb_define_method(rb_mEnumerable, "slice_before", enum_slice_before, -1);
     rb_define_method(rb_mEnumerable, "slice_after", enum_slice_after, -1);
     rb_define_method(rb_mEnumerable, "slice_when", enum_slice_when, 0);
Index: test/ruby/test_enum.rb
===================================================================
--- test/ruby/test_enum.rb	(revision 49917)
+++ test/ruby/test_enum.rb	(working copy)
@@ -481,22 +481,6 @@ class TestEnumerable < Test::Unit::TestC
     e = @obj.chunk {|elt| elt & 2 == 0 ? false : true }
     assert_equal([[false, [1]], [true, [2, 3]], [false, [1]], [true, [2]]], e.to_a)
 
-    e = @obj.chunk(acc: 0) {|elt, h| h[:acc] += elt; h[:acc].even? }
-    assert_equal([[false, [1,2]], [true, [3]], [false, [1,2]]], e.to_a)
-    assert_equal([[false, [1,2]], [true, [3]], [false, [1,2]]], e.to_a) # this tests h is duplicated.
-
-    hs = [{}]
-    e = [:foo].chunk(hs[0]) {|elt, h|
-      hs << h
-      true
-    }
-    assert_equal([[true, [:foo]]], e.to_a)
-    assert_equal([[true, [:foo]]], e.to_a)
-    assert_equal([{}, {}, {}], hs)
-    assert_not_same(hs[0], hs[1])
-    assert_not_same(hs[0], hs[2])
-    assert_not_same(hs[1], hs[2])
-
     e = @obj.chunk {|elt| elt < 3 ? :_alone : true }
     assert_equal([[:_alone, [1]],
                   [:_alone, [2]],
@@ -526,22 +510,6 @@ class TestEnumerable < Test::Unit::TestC
     e = @obj.slice_before {|elt| elt.odd? }
     assert_equal([[1,2], [3], [1,2]], e.to_a)
 
-    e = @obj.slice_before(acc: 0) {|elt, h| h[:acc] += elt; h[:acc].even? }
-    assert_equal([[1,2], [3,1,2]], e.to_a)
-    assert_equal([[1,2], [3,1,2]], e.to_a) # this tests h is duplicated.
-
-    hs = [{}]
-    e = [:foo].slice_before(hs[0]) {|elt, h|
-      hs << h
-      true
-    }
-    assert_equal([[:foo]], e.to_a)
-    assert_equal([[:foo]], e.to_a)
-    assert_equal([{}, {}, {}], hs)
-    assert_not_same(hs[0], hs[1])
-    assert_not_same(hs[0], hs[2])
-    assert_not_same(hs[1], hs[2])
-
     ss = %w[abc defg h ijk l mno pqr st u vw xy z]
     assert_equal([%w[abc defg h], %w[ijk l], %w[mno], %w[pqr st u vw xy z]],
                  ss.slice_before(/\A...\z/).to_a)
