Project

General

Profile

Actions

Bug #18558

closed

Numbered arguments + eval

Bug #18558: Numbered arguments + eval

Added by radarek (Radosław Bułat) almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin20]
[ruby-core:107347]

Description

def yield_2_args yield 1, 2 end yield_2_args { p [eval("_1"), _2] } 

Running with ruby 2.7.2, I get output:

[1, 2] [1, 2] 

With 3.0.2, I get output:

[1, 2] (eval):1:in `block in <main>': undefined local variable or method `_1' for main:Object (NameError)	from bug.rb:6:in `eval'	from bug.rb:6:in `block in <main>'	from bug.rb:2:in `yield_2_args'	from bug.rb:6:in `<main>' 

Is is intentional change between 2.7.x and 3.0.x?


Related issues 1 (0 open1 closed)

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago Actions #1

  • Related to Feature #16432: Using `_1` inside `binding.irb` will cause unintended behavior added

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago Actions #2 [ruby-core:107355]

  • Status changed from Open to Closed

Yes, see [Feature #16432].

Actions

Also available in: PDF Atom