From 37356b713ceb0d159f946269c8479854ceb2acee Mon Sep 17 00:00:00 2001 From: Nick Dower Date: Thu, 2 Jan 2025 17:24:55 +0100 Subject: [PATCH] YJIT: Add crashing test for yielding keyword args Code like the following is crashing for us on 3.4.1: ```ruby def a(&) = yield(x: 0) 1000.times { a { |x:| x } } ``` Crash: ``` ruby: YJIT has panicked. More info to follow... thread '' panicked at ./yjit/src/codegen.rs:8018:13: assertion `left == right` failed left: 0 right: 1 ``` Co-authored-by: Dani Acherkan --- bootstraptest/test_yjit.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 6a1aebccd7..8c6171bd0a 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -37,27 +37,35 @@ assert_equal "ok", %q{ } # test discarding extra yield arguments -assert_equal "2210150001501015", %q{ +assert_equal "22131300500015901015", %q{ def splat_kw(ary) = yield *ary, a: 1 def splat(ary) = yield *ary - def kw = yield 1, 2, a: 0 + def kw = yield 1, 2, a: 3 + + def kw_only = yield a: 0 def simple = yield 0, 1 + def none = yield + def calls [ splat([1, 1, 2]) { |x, y| x + y }, splat([1, 1, 2]) { |y, opt = raise| opt + y}, splat_kw([0, 1]) { |a:| a }, kw { |a:| a }, - kw { |a| a }, + kw { |one| one }, + kw { |one, a:| a }, + kw_only { |a:| a }, + kw_only { |a: 1| a }, simple { 5.itself }, simple { |a| a }, simple { |opt = raise| opt }, simple { |*rest| rest }, simple { |opt_kw: 5| opt_kw }, + none { |a: 9| a }, # autosplat ineractions [0, 1, 2].yield_self { |a, b| [a, b] }, [0, 1, 2].yield_self { |a, opt = raise| [a, opt] },