Project

General

Profile

Actions

Bug #18558

closed

Numbered arguments + eval

Added by radarek (Radosław Bułat) 7 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
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)

Related to Ruby master - Feature #16432: Using `_1` inside `binding.irb` will cause unintended behaviorClosedActions
Actions #1

Updated by nobu (Nobuyoshi Nakada) 7 months ago

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

Updated by nobu (Nobuyoshi Nakada) 7 months ago

  • Status changed from Open to Closed

Yes, see [Feature #16432].

Actions

Also available in: Atom PDF