From c4e30d28659fbe0dbe813b21ba8bdbd96c812a66 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Thu, 15 Feb 2024 20:29:06 -0500 Subject: YJIT: Support `**nil` This adds YJIT support for VM_CALL_KW_SPLAT with nil, specifically for when we already know from the context that it's done with a nil. This is enough to support forwarding with `...` when there no keyword arguments are present. Amend the kw_rest support to propagate the type of the parameter to help with this. Test interactions with splat, since the splat array sits lower on the stack when a kw_splat argument is present. --- test/ruby/test_yjit.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index f1b32226ec..b0a8337c11 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -1573,6 +1573,17 @@ class TestYJIT < Test::Unit::TestCase RUBY end + def test_kw_splat_nil + assert_compiles(<<~'RUBY', result: %i[ok ok], no_send_fallbacks: true) + def id(x) = x + def kw_fw(arg, **) = id(arg, **) + def fw(...) = id(...) + def use = [fw(:ok), kw_fw(:ok)] + + use + RUBY + end + private def code_gc_helpers -- cgit v1.2.3