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

merge revision(s) e83c02a768: [Backport #18289]

Delegate keywords from Enumerable#to_a to #each

	Fixes [Bug #18289]
	---
	 enum.c                 | 2 +-
	 test/ruby/test_enum.rb | 5 +++++
	 2 files changed, 6 insertions(+), 1 deletion(-)
This commit is contained in:
nagachika 2021-11-23 14:20:49 +09:00
parent b6f87d527f
commit aadb8cad56
3 changed files with 7 additions and 2 deletions

2
enum.c
View file

@ -682,7 +682,7 @@ enum_to_a(int argc, VALUE *argv, VALUE obj)
{
VALUE ary = rb_ary_new();
rb_block_call(obj, id_each, argc, argv, collect_all, ary);
rb_block_call_kw(obj, id_each, argc, argv, collect_all, ary, RB_PASS_CALLED_KEYWORDS);
return ary;
}

View file

@ -134,6 +134,11 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([1, 2, 3, 1, 2], @obj.to_a)
end
def test_to_a_keywords
def @obj.each(foo:) yield foo end
assert_equal([1], @obj.to_a(foo: 1))
end
def test_to_a_size_symbol
sym = Object.new
class << sym

View file

@ -12,7 +12,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 3
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 151
#define RUBY_PATCHLEVEL 152
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 11