Issue #16293 has been updated by osyo (manga osyo).


Thank you all.
I updated text.

----------------------------------------
Feature #16293: Numbered parameter confirmation in Ruby 2.7
https://bugs.ruby-lang.org/issues/16293#change-82503

* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------

## Overview

I want to make a final check on the behavior of Numbered parameter( No warning or Warning or Error).
There is a difference in [DevelopersMeeting20190829Japan logs](https://docs.google.com/document/d/1XypDO1crRV9uNg1_ajxkljVdN8Vdyl5hnz462bDQw34/edit) and behavior.


## Ruby version

```ruby
p RUBY_VERSION
# => "2.7.0"
p RUBY_DESCRIPTION
# => "ruby 2.7.0dev (2019-11-02T06:32:49Z trunk 772b0613c5) [x86_64-linux]"
p RUBY_RELEASE_DATE
# => "2019-11-02"
p RUBY_REVISION
# => "772b0613c583773cd2eda23bce8275926a351e79"
```


## [DevelopersMeeting20190829Japan logs](https://docs.google.com/document/d/1XypDO1crRV9uNg1_ajxkljVdN8Vdyl5hnz462bDQw34/edit)

* local variables (parameters and assigned variable) ¢ª force warning (Don¡Çt use) on Ruby 2.7 and syntax error on Ruby 3.
* method invocation
  * vcall: `x = _0 # expect _0()` outside block. ¢ª force warning on Ruby 2.7 and syntax error on Ruby 3.
  * vcall: `1.times{ _0 }` ¢ª block parameter (incompatibility)
  * vcall: `1.times{|i| _0 }` ¢ª force warning on Ruby 2.7 and syntax error on Ruby 3.
* method invocation (`x = _0(), x = foo._0`) ¢ª no warning
* method name (`def _0(); end`) ¢ª no warning


## Proposal

```ruby
def _1; end

# expected: warning: `_1' is used as numbered parameter
# actual: No warning
# reason: Because "`x = _0 # expect _0()` outside block. ¢ª force warning on Ruby 2.7 and syntax error on Ruby 3" is written in the log
x = _1

# expected: warning: `_1' is used as numbered parameter
#           and call to _1()
# actual: Error: numbered parameter outside block (SyntaxError)
# reason: Because hoge() method is called with `eval("hoge")`
eval("_1")
```

```ruby
def _1; end

# expected: warning: `_1' is used as numbered parameter
#           and call to _1()
# actual: Error: ordinary parameter is defined
# reason: Because "`1.times{|i| _0 }` ¢ª force warning on Ruby 2.7 and syntax error on Ruby 3." is written in the log
proc { |i| _1 }.call 42
```

```ruby
# expected: warning: `_1' is used as numbered parameter
# actual: No warning
# reason: Because define local variable _1 is warning
def hgoe(_1)
end
```

```ruby
proc {
  # Warning
  _1 = 42
}

proc {
  _1
  # expected: warning: `_1' is used as numbered parameter
  # actual: No warning
  # reason: Because define local variable _1 is warning
  _1 = 42
}
```

## :MEMO: Other behavior

* Other current behavior : https://gist.github.com/osyo-manga/f332ba1f31dbc3a437acd4d86d7986dc
* Is there any other syntax to change `No warning` `Warning` `Error` ?
* Considering compatibility, make it Warning instead of Error ?


Are there other edge cases for Numbered parameter?
Thank you :)





-- 
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>