From: manga.osyo@... Date: 2019-11-06T00:58:27+00:00 Subject: [ruby-core:95716] [Ruby master Feature#16293] Numbered parameter confirmation in Ruby 2.7 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: