diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-24 15:02:01 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-24 15:02:01 +0000 |
commit | 0d0d5e9f717aa1e0c1f830ffcf0908c51a049712 (patch) | |
tree | 9e61dd6bf8f7e4815c58eadbfe96fd7afaad1f06 | |
parent | 470103861e5b071393676836c9ede947bfea16bb (diff) | |
download | ruby-0d0d5e9f717aa1e0c1f830ffcf0908c51a049712.tar.gz |
* array.c (rb_ary_index, rb_ary_rindex): Emit a warning that a
given block is unused when an argument is specified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 4 |
2 files changed, 9 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Tue Feb 24 23:58:52 2009 Akinori MUSHA <knu@iDaemons.org> + + * array.c (rb_ary_index, rb_ary_rindex): Emit a warning that a + given block is unused when an argument is specified. + Tue Feb 24 22:00:37 2009 Tanaka Akira <akr@fsij.org> * ext/socket/socket.c (sockaddr_obj): convert fe80:1::1 to fe80::1%1. @@ -1128,6 +1128,8 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary) return Qnil; } rb_scan_args(argc, argv, "1", &val); + if (rb_block_given_p()) + rb_warn("given block not used"); for (i=0; i<RARRAY_LEN(ary); i++) { if (rb_equal(RARRAY_PTR(ary)[i], val)) return LONG2NUM(i); @@ -1168,6 +1170,8 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary) return Qnil; } rb_scan_args(argc, argv, "1", &val); + if (rb_block_given_p()) + rb_warn("given block not used"); while (i--) { if (rb_equal(RARRAY_PTR(ary)[i], val)) return LONG2NUM(i); |