Added byahogappa (sho hirano)about 2 months ago. Updatedabout 2 months ago.
Description
When Ruby::Box is enabled (RUBY_BOX=1), accessing$! before araise statement causes$! to benil inside the subsequentrescue block, instead of containing the raised exception.
# test.rbbegin$!# Accessing $! before raise triggers the bugraise"test error"rescueputs"$! =#{$!.inspect}"end$ ruby test.rb
$! = #<RuntimeError: test error>
$ RUBY_BOX=1 ruby test.rb
$! = nil
$! should contain the raised exception (#<RuntimeError: test error>) inside the rescue block, regardless of whether $! was accessed before the raise.
When RUBY_BOX=1 is set and $! is accessed before raise, $! becomes nil inside the rescue block.