From 771a2f039b9a059a73e8f111d1d46590fa697f63 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 25 Jan 2024 12:44:13 -0800 Subject: Fix incorrect use of VM_CALL_KW_SPLAT_MUT in zsuper with keyword splat For zsuper calls with a keyword splat but no actual keywords, the keyword splat is passed directly, so it cannot be mutable, because if the callee accepts a keyword splat, changes to the keyword splat by the callee would be reflected in the caller. While here, simplify the logic when the method supports literal keywords. I don't think it is possible for a method with has_kw param flags to not have keywords, so add an assertion for that, and set VM_CALL_KW_SPLAT_MUT in a single place. --- test/ruby/test_super.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index 6a575b88c5..ce78e66c52 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -558,6 +558,18 @@ class TestSuper < Test::Unit::TestCase end end + def test_zsuper_kw_splat_not_mutable + extend(Module.new{def a(**k) k[:a] = 1 end}) + extend(Module.new do + def a(**k) + before = k.dup + super + [before, k] + end + end) + assert_equal(*a) + end + def test_from_eval bug10263 = '[ruby-core:65122] [Bug #10263a]' a = Class.new do -- cgit v1.2.3