diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | enum.c | 9 |
3 files changed, 15 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Thu Mar 3 17:10:49 2011 Akinori MUSHA <[email protected]> + + * array.c (rb_ary_collect), enum.c (enum_collect): Add + compatibility warnings for a call without a block. + Fri Feb 18 20:46:55 2011 Shugo Maeda <[email protected]> * lib/fileutils.rb (FileUtils::remove_entry_secure): there is a @@ -1902,6 +1902,8 @@ rb_ary_collect(ary) VALUE collect; if (!rb_block_given_p()) { + rb_warn("Array#%s without a block does not return an array in 1.9 and later", + rb_id2name(rb_frame_last_func())); return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr); } @@ -430,7 +430,14 @@ enum_collect(obj) { VALUE ary = rb_ary_new(); - rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : collect_all, ary); + if (!rb_block_given_p()) { + rb_warn("Enumerable#%s without a block does not return an array in 1.9 and later", + rb_id2name(rb_frame_last_func())); + rb_iterate(rb_each, obj, collect_all, ary); + } + else { + rb_iterate(rb_each, obj, collect_i, ary); + } return ary; } |