@@ -75,19 +75,58 @@ def test_lazy_block
7575 end
7676 assert_equal true , x , '[Bug #15105]'
7777 end
78+ end
79+
80+ # This is a YJIT test, but we can't test this without a C extension that calls
81+ # rb_debug_inspector_open(), so we're testing it using "-test-/debug" here.
82+ class TestDebugWithYJIT < Test ::Unit ::TestCase
83+ class LocalSetArray
84+ def to_a
85+ Bug ::Debug . inspector . each do |_ , binding , |
86+ binding . local_variable_set ( :local , :ok ) if binding
87+ end
88+ [ :ok ]
89+ end
90+ end
91+
92+ class DebugArray
93+ def to_a
94+ Bug ::Debug . inspector
95+ [ :ok ]
96+ end
97+ end
98+
99+ def test_yjit_invalidates_getlocal_after_splatarray
100+ val = getlocal_after_splatarray ( LocalSetArray . new )
101+ assert_equal [ :ok , :ok ] , val
102+ end
78103
79- # This is a YJIT test, but we can't test this without a C extension that calls
80- # rb_debug_inspector_open(), so we're testing it using "-test-/debug" here.
81- def test_yjit_invalidates_setlocal_after_inspector_call
104+ def test_yjit_invalidates_setlocal_after_splatarray
105+ val = setlocal_after_splatarray ( DebugArray . new )
106+ assert_equal [ :ok ] , val
107+ end
108+
109+ def test_yjit_invalidates_setlocal_after_proc_call
82110 val = setlocal_after_proc_call ( proc { Bug ::Debug . inspector ; :ok } )
83111 assert_equal :ok , val
84- end if defined? ( RubyVM :: YJIT ) && RubyVM :: YJIT . enabled?
112+ end
85113
86114 private
87115
116+ def getlocal_after_splatarray ( array )
117+ local = 1
118+ [ *array , local ]
119+ end
120+
121+ def setlocal_after_splatarray ( array )
122+ local = *array # setlocal followed by splatarray
123+ itself # split a block using a C call
124+ local # getlocal
125+ end
126+
88127 def setlocal_after_proc_call ( block )
89128 local = block . call # setlocal followed by OPTIMIZED_METHOD_TYPE_CALL
90129 itself # split a block using a C call
91130 local # getlocal
92131 end
93- end
132+ end if defined? ( RubyVM :: YJIT ) && RubyVM :: YJIT . enabled?
0 commit comments