summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-24 18:25:32 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-24 21:57:54 +0900
commit0e84eecc1764ec6e2a28654b3e66b8c006f73432 (patch)
treee63fb045e9b1b683bb04988d31ee9466319e5911 /test
parentea68bb914a3c806a1c5188993b96791a76ab0849 (diff)
Make numbered parameters exclusive in a scope
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2431
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 31175ebae9..61bee816b6 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1453,6 +1453,10 @@ eom
assert_syntax_error('proc {|x| _1}', /ordinary parameter is defined/)
assert_syntax_error('proc {_0+_1}', /implicit parameter is used/)
assert_syntax_error('proc {_1+_0}', /numbered parameter is used/)
+ assert_syntax_error('proc {_1; proc {_2}}', /numbered parameter is already used/)
+ assert_syntax_error('proc {proc {_1}; _2}', /numbered parameter is already used/)
+ assert_syntax_error('proc {_0; proc {_1}}', /implicit parameter is already used/)
+ assert_syntax_error('proc {proc {_0}; _1}', /implicit parameter is already used/)
assert_syntax_error('->(){_0}', /ordinary parameter is defined/)
assert_syntax_error('->(){_1}', /ordinary parameter is defined/)
assert_syntax_error('->(x){_1}', /ordinary parameter is defined/)
@@ -1461,6 +1465,10 @@ eom
assert_syntax_error('->x=_1{}', /ordinary parameter is defined/)
assert_syntax_error('-> {_0+_1}', /implicit parameter is used/)
assert_syntax_error('-> {_1+_0}', /numbered parameter is used/)
+ assert_syntax_error('-> {_1; -> {_2}}', /numbered parameter is already used/)
+ assert_syntax_error('-> {-> {_1}; _2}', /numbered parameter is already used/)
+ assert_syntax_error('-> {_0; -> {_1}}', /implicit parameter is already used/)
+ assert_syntax_error('-> {-> {_0}; _1}', /implicit parameter is already used/)
assert_warn(/`_1' is used as numbered parameter/) {eval('proc {_1 = nil}')}
assert_warn(/`_2' is used as numbered parameter/) {eval('_2=1')}
end