diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb index a272d9d0dd94a5..67a94ed7af7015 100644 --- a/test/ruby/test_call.rb +++ b/test/ruby/test_call.rb @@ -100,6 +100,12 @@ def test_invalid_safe_call } end + def test_frozen_splat_and_keywords + a = [1, 2].freeze + def self.f(*a); a end + assert_equal([1, 2, {kw: 3}], f(*a, kw: 3)) + end + def test_call_bmethod_proc pr = proc{|sym| sym} define_singleton_method(:a, &pr) diff --git a/vm_args.c b/vm_args.c index 92e141bf6e8cbe..14ae550d2f1b8f 100644 --- a/vm_args.c +++ b/vm_args.c @@ -542,11 +542,13 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co else if (UNLIKELY(ISEQ_BODY(iseq)->param.flags.ruby2_keywords)) { converted_keyword_hash = check_kwrestarg(converted_keyword_hash, &kw_flag); flag_keyword_hash = converted_keyword_hash; + arg_rest_dup(args); rb_ary_push(args->rest, converted_keyword_hash); keyword_hash = Qnil; } else if (!ISEQ_BODY(iseq)->param.flags.has_kwrest && !ISEQ_BODY(iseq)->param.flags.has_kw) { converted_keyword_hash = check_kwrestarg(converted_keyword_hash, &kw_flag); + arg_rest_dup(args); rb_ary_push(args->rest, converted_keyword_hash); keyword_hash = Qnil; } else {