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

ruby-changes:27277

From: nobu <ko1@a...>
Date: Wed, 20 Feb 2013 12:16:11 +0900 (JST)
Subject: [ruby-changes:27277] nobu:r39329 (trunk): enumerator.c: suppress warnings

nobu	2013-02-20 12:15:32 +0900 (Wed, 20 Feb 2013)

  New Revision: 39329

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

  Log:
    enumerator.c: suppress warnings
    
    * enumerator.c (lazy_zip_arrays_func, lazy_zip_func, lazy_take_func),
      (lazy_drop_func, lazy_drop_while_func): suppress uninitialized
      instance vriable warnings.

  Modified files:
    trunk/enumerator.c
    trunk/test/ruby/test_lazy_enumerator.rb

Index: enumerator.c
===================================================================
--- enumerator.c	(revision 39328)
+++ enumerator.c	(revision 39329)
@@ -1631,7 +1631,7 @@ lazy_zip_arrays_func(VALUE val, VALUE ar https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1631
     long i, count;
 
     yielder = argv[0];
-    memo = rb_ivar_get(yielder, id_memo);
+    memo = rb_attr_get(yielder, id_memo);
     count = NIL_P(memo) ? 0 : NUM2LONG(memo);
 
     ary = rb_ary_new2(RARRAY_LEN(arrays) + 1);
@@ -1651,7 +1651,7 @@ lazy_zip_func(VALUE val, VALUE zip_args, https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1651
     long i;
 
     yielder = argv[0];
-    arg = rb_ivar_get(yielder, id_memo);
+    arg = rb_attr_get(yielder, id_memo);
     if (NIL_P(arg)) {
 	arg = rb_ary_new2(RARRAY_LEN(zip_args));
 	for (i = 0; i < RARRAY_LEN(zip_args); i++) {
@@ -1708,7 +1708,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1708
 lazy_take_func(VALUE val, VALUE args, int argc, VALUE *argv)
 {
     long remain;
-    VALUE memo = rb_ivar_get(argv[0], id_memo);
+    VALUE memo = rb_attr_get(argv[0], id_memo);
     if (NIL_P(memo)) {
 	memo = args;
     }
@@ -1791,7 +1791,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1791
 lazy_drop_func(VALUE val, VALUE args, int argc, VALUE *argv)
 {
     long remain;
-    VALUE memo = rb_ivar_get(argv[0], id_memo);
+    VALUE memo = rb_attr_get(argv[0], id_memo);
     if (NIL_P(memo)) {
 	memo = args;
     }
@@ -1820,7 +1820,7 @@ lazy_drop(VALUE obj, VALUE n) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1820
 static VALUE
 lazy_drop_while_func(VALUE val, VALUE args, int argc, VALUE *argv)
 {
-    VALUE memo = rb_ivar_get(argv[0], id_memo);
+    VALUE memo = rb_attr_get(argv[0], id_memo);
     if (NIL_P(memo) && !RTEST(rb_yield_values2(argc - 1, &argv[1]))) {
 	rb_ivar_set(argv[0], id_memo, memo = Qtrue);
     }
Index: test/ruby/test_lazy_enumerator.rb
===================================================================
--- test/ruby/test_lazy_enumerator.rb	(revision 39328)
+++ test/ruby/test_lazy_enumerator.rb	(revision 39329)
@@ -463,4 +463,13 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_lazy_enumerator.rb#L463
     end
     assert_equal Enumerator::Lazy, [].lazy.chunk{}.class, bug7507
   end
+
+  def test_no_warnings
+    le = (1..3).lazy
+    assert_warning("") {le.zip([4,5,6]).force}
+    assert_warning("") {le.zip(4..6).force}
+    assert_warning("") {le.take(1).force}
+    assert_warning("") {le.drop(1).force}
+    assert_warning("") {le.drop_while{false}.force}
+  end
 end

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

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