Actions
Bug #16293
closedNumbered parameter confirmation in Ruby 2.7
    Bug #16293:
    Numbered parameter confirmation in Ruby 2.7
  
Description
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 and behavior.
Ruby version¶
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¶
- 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.
 
- vcall: 
- method invocation (x = _0(), x = foo._0) → no warning
- method name (def _0(); end) → no warning
Proposal¶
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")
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
# expected: warning: `_1' is used as numbered parameter
# actual: No warning
# reason: Because define local variable _1 is warning
def hgoe(_1)
end
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 warningWarningError?
- Considering compatibility, make it Warning instead of Error ?
Are there other edge cases for Numbered parameter?
Thank you :)
Actions