summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorKoichi Sasada <[email protected]>2024-06-13 11:48:48 +0900
committerKoichi Sasada <[email protected]>2024-06-13 13:52:39 +0900
commitfc33559c40e08e4ae0a98821a679abddc4bb247c (patch)
tree19bb81167633e85dbfcd8d4a37ebed8c87abfefa /test/ruby
parente4385baaa2bfe4c0a6540f4c996df4ccff71cdca (diff)
clear `kw_flag` if given hash is nil
https://bugs.ruby-lang.org/issues/20570 is caused I missed to clear the `kw_flag` even if `keyword_hash` is nil.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_keyword.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 34a80c3729..7a9cd74b40 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -4523,6 +4523,24 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase
assert_equal({one: 1, two: 2}, f.call(one:, two:))
end
+ def m_bug20570(*a, **nil)
+ a
+ end
+
+ def test_splat_arg_with_prohibited_keyword
+ assert_equal([], m_bug20570(*[]))
+ assert_equal([1], m_bug20570(*[1]))
+ assert_equal([1, 2], m_bug20570(*[1, 2]))
+ h = nil
+ assert_equal([], m_bug20570(*[], **h))
+ assert_equal([1], m_bug20570(*[1], **h))
+ assert_equal([1, 2], m_bug20570(*[1, 2], **h))
+
+ assert_equal([], m_bug20570(*[], **nil))
+ assert_equal([1], m_bug20570(*[1], **nil))
+ assert_equal([1, 2], m_bug20570(*[1, 2], **nil))
+ end
+
private def one
1
end