Movatterモバイル変換


[0]ホーム

URL:


Project

General

Profile

Ruby

Ruby

Custom queries

Actions

Bug #21823

open

$! is nil inside rescue block when $! is accessed before raise in Ruby::Box

Bug #21823:$! is nil inside rescue block when $! is accessed before raise in Ruby::Box

Added byahogappa (sho hirano)about 2 months ago. Updatedabout 2 months ago.

Status:
Open
Target version:
-
ruby -v:
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25]
[ruby-core:<unknown>]
Tags:

Description

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.

Reproduction

# test.rbbegin$!# Accessing $! before raise triggers the bugraise"test error"rescueputs"$! =#{$!.inspect}"end

Without Ruby::Box:

$ ruby test.rb
$! = #<RuntimeError: test error>

With Ruby::Box:

$ RUBY_BOX=1 ruby test.rb
$! = nil

Expected behavior

$! should contain the raised exception (#<RuntimeError: test error>) inside the rescue block, regardless of whether $! was accessed before the raise.

Actual behavior

When RUBY_BOX=1 is set and $! is accessed before raise, $! becomes nil inside the rescue block.

Updated bynobu (Nobuyoshi Nakada)about 2 months agoActions#1

  • Tags set tobox
  • Assignee set totagomoris (Satoshi Tagomori)
  • Backport changed from3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: REQUIRED
Actions

Also available in:PDFAtom

Powered byRedmine © 2006-2026 Jean-Philippe Lang
Loading...

[8]ページ先頭

©2009-2026 Movatter.jp