1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-02-20 03:15:32 +00:00
parent 2d112d2c78
commit 4b81b403eb
2 changed files with 14 additions and 5 deletions

View file

@ -1631,7 +1631,7 @@ lazy_zip_arrays_func(VALUE val, VALUE arrays, int argc, VALUE *argv)
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, int argc, VALUE *argv)
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
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
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)
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);
}

View file

@ -463,4 +463,13 @@ EOS
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