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

enum.c: fix condition to recycle block argument

* 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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-04-16 14:47:38 +00:00
parent fcbd13b10a
commit 118838ad3a
3 changed files with 17 additions and 1 deletions

View file

@ -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> Wed Apr 16 09:51:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/openssl/ossl_pkey.c (ossl_pkey_verify): as EVP_VerifyFinal() * ext/openssl/ossl_pkey.c (ossl_pkey_verify): as EVP_VerifyFinal()

2
enum.c
View file

@ -2058,7 +2058,7 @@ enum_each_entry(int argc, VALUE *argv, VALUE obj)
return 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 #define nd_no_recycle u2.value
static VALUE static VALUE

View file

@ -342,12 +342,22 @@ class TestEnumerable < Test::Unit::TestCase
ary = [] ary = []
(1..10).each_slice(3) {|a| ary << a} (1..10).each_slice(3) {|a| ary << a}
assert_equal([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], ary) 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 end
def test_each_cons def test_each_cons
ary = [] ary = []
(1..5).each_cons(3) {|a| ary << a} (1..5).each_cons(3) {|a| ary << a}
assert_equal([[1, 2, 3], [2, 3, 4], [3, 4, 5]], ary) 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 end
def test_zip def test_zip