diff --git a/compile.c b/compile.c index 366d32f9ec..cf75dce619 100644 --- a/compile.c +++ b/compile.c @@ -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; } diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb index 570b5bb0a9..14847bf629 100644 --- a/test/ruby/test_call.rb +++ b/test/ruby/test_call.rb @@ -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 = []