Issue #16340 has been reported by osyo (manga osyo).

----------------------------------------
Bug #16340: There are cases where `eval("_ 1")` does not refer to Numbered parameter
https://bugs.ruby-lang.org/issues/16340

* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-11-11T10:03:43Z trunk 9d3213ac85) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------

## Steps to reproduce

1. Define local variable `_1` outside block
2. Call Numbered parameter in block
3. Call `eval("_1")` in same block


## Expected behavior

```ruby
_1 = :local_variable
proc {
  _1
  # return Numbered parameter(_1)
  eval("_1") # => :argument
}.call :argument
```


## Actual behavior

```ruby
_1 = :local_variable
proc {
  _1
  # return local variables outside block
  eval("_1") # => :local_variable
}.call :argument
```

This is strange behavior because I want to expect to reference `_1` in block.


## Note

* Return Numbered parameter if not define local variables outside block

```ruby
# _1 = :local_variable
proc {
  _1
  # Actual behavior
  # return Numbered parameter
  eval("_1") # => :argument
}.call :argument
```





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>