ml.ruby-lang.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

ruby-dev

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
ruby-dev@ml.ruby-lang.org

April 2026

  • 1 participants
  • 1 discussions
[ruby-dev:52204] [Ruby Bug#21933] Ruby::Box: named capture local variable can become nil after non-matching lines
by katsyoshi (Katsuyoshi MATSUMOTO) 02 Apr '26

02 Apr '26
Issue #21933 has been reported by katsyoshi (Katsuyoshi MATSUMOTO). ---------------------------------------- Bug #21933: Ruby::Box: named capture local variable can become nil after non-matching lines https://bugs.ruby-lang.org/issues/21933 * Author: katsyoshi (Katsuyoshi MATSUMOTO) * Status: Open * ruby -v: 4.0.1 * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Environment: - Ruby 4.0.1 - RUBY_BOX=1 - OS: Linux x86_64 Summary: With Ruby::Box enabled, a named capture local variable from `=~` may become nil, even when the regexp matches. This happens after iterating over non-matching lines first. Reproducer: sample.rb ``` ruby text = <<~ASM .intel_syntax noprefix .globl main main: nop ASM cur=nil text.each_line do |line| if /^(?<label>[_A-Za-z.]\w*):/ =~ line p [:matched, line.inspect, label.inspect] cur = label break end end p [:cur, cur.inspect] ``` ``` shell Expected: [:matched, "\"main:\\n\"", "\"main\""] [:cur, "\"main\""] ``` Actual (with RUBY_BOX=1): ``` shell [:matched, "\"main:\\n\"", "nil"] [:cur, "nil"] ``` Control: Without RUBY_BOX=1, the same script returns "main" as expected. -- https://bugs.ruby-lang.org/
3 2
0 0

HyperKitty Powered by HyperKitty version 1.3.12.