summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-11-05 07:08:21 -0700
committerJeremy Evans <code@jeremyevans.net>2021-11-05 06:22:14 -0900
commite83c02a768af61cd0890a75e90bcae1119d8bd93 (patch)
tree84ecc55409c1316bdbceb92eaa9fc4ac642987c0
parent907aa4752752869193f333c4114da85080ec03e3 (diff)
Delegate keywords from Enumerable#to_a to #each
Fixes [Bug #18289]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5086
-rw-r--r--enum.c2
-rw-r--r--test/ruby/test_enum.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/enum.c b/enum.c
index d3384f523e..a51b90296b 100644
--- a/enum.c
+++ b/enum.c
@@ -713,7 +713,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;
}
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 702c332cd2..c4706323fd 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -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