diff options
author | Jeremy Evans <code@jeremyevans.net> | 2023-10-30 11:52:02 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2023-11-18 09:44:42 -0800 |
commit | ae48d4ad2ef7abbf116ff28b2cd3748d4c654d80 (patch) | |
tree | 9026c68368de1ba67d116fa7b2b3e977b1725f30 /test/ruby/test_call.rb | |
parent | c56dd94db0001b900a2dab3ee350a182d6bb42af (diff) |
Ensure keyword splat method argument is hash
Commit e87d0882910001ef3b0c2ccd43bf00cee8c34a0c introduced a
regression where the keyword splat object passed by the caller
would be directly used by callee as keyword splat parameters,
if it implemented #to_hash. The return value of #to_hash would be
ignored in this case.
Diffstat (limited to 'test/ruby/test_call.rb')
-rw-r--r-- | test/ruby/test_call.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb index 88a0df4388..a272d9d0dd 100644 --- a/test/ruby/test_call.rb +++ b/test/ruby/test_call.rb @@ -132,6 +132,15 @@ class TestCall < Test::Unit::TestCase assert_equal([0, 1, 2, b], aaa(0, *ary, &ary.pop), bug16504) end + def test_call_args_splat_with_nonhash_keyword_splat + o = Object.new + def o.to_hash; {a: 1} end + def self.f(*a, **kw) + kw + end + assert_equal Hash, f(*[], **o).class + end + OVER_STACK_LEN = (ENV['RUBY_OVER_STACK_LEN'] || 150).to_i # Greater than VM_ARGC_STACK_MAX OVER_STACK_ARGV = OVER_STACK_LEN.times.to_a.freeze |