ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: manga.osyo@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95786] [Ruby master Bug#16340] There are cases where `eval("_ 1")` does not refer to Numbered parameter
Date: Mon, 11 Nov 2019 12:45:06 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-16340.20191111124505.89ba178fa5216352@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16340.20191111124505@ruby-lang.org

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/

       reply	other threads:[~2019-11-11 12:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-16340.20191111124505@ruby-lang.org>
2019-11-11 12:45 ` manga.osyo [this message]
2019-11-11 13:40 ` [ruby-core:95787] [Ruby master Bug#16340] There are cases where `eval("_ 1")` does not refer to Numbered parameter eregontp
2019-11-13 15:31 ` [ruby-core:95844] " manga.osyo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-16340.20191111124505.89ba178fa5216352@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).