mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
Do not apply anon_rest optimization when passed array uses keyword-flagged hash
The optimization sets args->rest_dupped to avoid allocating an array, but this is not safe if the splat array ends in a keyword flagged hash. Unset args->rest_dupped in this case. Fixes [Bug #20388]
This commit is contained in:
parent
a2ac28d8ab
commit
2dbcc123f4
2 changed files with 16 additions and 0 deletions
|
@ -2835,6 +2835,19 @@ class TestKeywordArguments < Test::Unit::TestCase
|
|||
assert_equal({a: 1}, kw)
|
||||
end
|
||||
|
||||
def test_anon_splat_ruby2_keywords_bug_20388
|
||||
extend(Module.new{def process(action, ...) 1 end})
|
||||
extend(Module.new do
|
||||
def process(action, *args)
|
||||
args.freeze
|
||||
super
|
||||
end
|
||||
ruby2_keywords :process
|
||||
end)
|
||||
|
||||
assert_equal(1, process(:foo, bar: :baz))
|
||||
end
|
||||
|
||||
def test_top_ruby2_keywords
|
||||
assert_in_out_err([], <<-INPUT, ["[1, 2, 3]", "{:k=>1}"], [])
|
||||
def bar(*a, **kw)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue