Remove incorrect setting of KW_SPLAT_MUT flag

Fixes [Bug #20701]

Co-authored-by: Pablo Herrero <pablodherrero@gmail.com>
This commit is contained in:
Jeremy Evans 2024-08-27 09:08:22 -07:00 committed by GitHub
parent 2459e79b80
commit a3562c2a0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-08-27 16:08:42 +00:00
Merged: https://github.com/ruby/ruby/pull/11468

Merged-By: jeremyevans <code@jeremyevans.net>
2 changed files with 12 additions and 1 deletions

View File

@ -6249,7 +6249,6 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
if (kwnode) {
// kwsplat
*flag_ptr |= VM_CALL_KW_SPLAT;
*flag_ptr |= VM_CALL_KW_SPLAT_MUT;
compile_hash(iseq, args, kwnode, TRUE, FALSE);
argc += 1;
}

View File

@ -345,6 +345,18 @@ class TestCall < Test::Unit::TestCase
assert_equal Hash, f(*[], **o).class
end
def test_call_args_splat_with_pos_arg_kw_splat_is_not_mutable
o = Object.new
def o.foo(a, **h)= h[:splat_modified] = true
a = []
b = {splat_modified: false}
o.foo(*a, :x, **b)
assert_equal({splat_modified: false}, b)
end
def test_kwsplat_block_order
o = Object.new
ary = []