summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--enum.c2
-rw-r--r--test/ruby/test_enum.rb10
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b4efef..ba75a52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Apr 16 23:47:36 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * enum.c (dont_recycle_block_arg): fix condition to recycle block
+ argument. lambda with rest can get internal array directly.
+ [ruby-core:62060] [Bug #9749]
+
Wed Apr 16 09:51:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/openssl/ossl_pkey.c (ossl_pkey_verify): as EVP_VerifyFinal()
diff --git a/enum.c b/enum.c
index 8826bf3..8496636 100644
--- a/enum.c
+++ b/enum.c
@@ -2058,7 +2058,7 @@ enum_each_entry(int argc, VALUE *argv, VALUE obj)
return obj;
}
-#define dont_recycle_block_arg(arity) ((arity) == 1 || (arity) == -1)
+#define dont_recycle_block_arg(arity) ((arity) == 1 || (arity) < 0)
#define nd_no_recycle u2.value
static VALUE
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 0fbfeeb..963cd94 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -342,12 +342,22 @@ class TestEnumerable < Test::Unit::TestCase
ary = []
(1..10).each_slice(3) {|a| ary << a}
assert_equal([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], ary)
+
+ bug9749 = '[ruby-core:62060] [Bug #9749]'
+ ary.clear
+ (1..10).each_slice(3, &lambda {|a, *| ary << a})
+ assert_equal([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], ary, bug9749)
end
def test_each_cons
ary = []
(1..5).each_cons(3) {|a| ary << a}
assert_equal([[1, 2, 3], [2, 3, 4], [3, 4, 5]], ary)
+
+ bug9749 = '[ruby-core:62060] [Bug #9749]'
+ ary.clear
+ (1..5).each_cons(3, &lambda {|a, *| ary << a})
+ assert_equal([[1, 2, 3], [2, 3, 4], [3, 4, 5]], ary, bug9749)
end
def test_zip