summaryrefslogtreecommitdiff
path: root/test/ruby/test_method_cache.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2025-12-02 17:34:36 -0800
committerJeremy Evans <code@jeremyevans.net>2025-12-10 05:44:50 +0900
commit6409715212d22699bd2751a363b050a5d8b94b83 (patch)
treed017ea4255b68d80097c3edfea32104d8e9838f4 /test/ruby/test_method_cache.rb
parentbd0d08b6d20e4145e472578d47164fcce14c0abf (diff)
Fix allocationless anonymous splat keyword argument check
Previously, if an argument splat and keywords are provided by the caller, it did not check whether the method/proc accepted keywords before avoiding the allocation. This is incorrect, because if the method/proc does not accept keywords, the keywords passed by the caller are added as a positional argument, so there must be an allocation to avoid mutating the positional splat argument. Add a check that if the caller passes keywords, the method/proc must accept keywords in order to optimize. If the caller passes a keyword splat, either the method/proc must accept keywords, or the keyword splat must be empty in order to optimize. If keywords are explicitly disallowed via `**nil`, the optimization should be skipped, because the array is mutated before the ArgumentError exception is raised. In addition to a test for the correct behavior, add an allocation test for a method that accepts an anonymous splat without keywords. Fixes [Bug #21757]
Diffstat (limited to 'test/ruby/test_method_cache.rb')
0 files changed, 0 insertions, 0 deletions