ruby-changes:18977
From: knu <ko1@a...>
Date: Thu, 3 Mar 2011 17:19:09 +0900 (JST)
Subject: [ruby-changes:18977] Ruby:r31013 (ruby_1_8): * array.c (rb_ary_collect), enum.c (enum_collect): Add
knu 2011-03-03 17:11:16 +0900 (Thu, 03 Mar 2011) New Revision: 31013 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31013 Log: * array.c (rb_ary_collect), enum.c (enum_collect): Add compatibility warnings for a call without a block. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/array.c branches/ruby_1_8/enum.c Index: ruby_1_8/array.c =================================================================== --- ruby_1_8/array.c (revision 31012) +++ ruby_1_8/array.c (revision 31013) @@ -1902,6 +1902,8 @@ 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); } Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 31012) +++ ruby_1_8/ChangeLog (revision 31013) @@ -1,3 +1,8 @@ +Thu Mar 3 17:10:49 2011 Akinori MUSHA <knu@i...> + + * 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 <shugo@r...> * lib/fileutils.rb (FileUtils::remove_entry_secure): there is a Index: ruby_1_8/enum.c =================================================================== --- ruby_1_8/enum.c (revision 31012) +++ ruby_1_8/enum.c (revision 31013) @@ -430,7 +430,14 @@ { 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/