mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix use of numbered parameter inside proc that is default value of optarg
This allows cases such as: ```ruby m ->(a = ->{@1}) {a} m.call.call(1) m2 ->(a: ->{@1}) {a} m2.call.call(2) ``` Previously, this would cause a syntax error. [Bug#15789]
This commit is contained in:
parent
b8f3be295b
commit
0c0ed1cee8
1 changed files with 2 additions and 0 deletions
|
@ -1312,6 +1312,8 @@ eom
|
|||
assert_equal(3, eval('[1,2].then {@1+@2}'))
|
||||
assert_equal("12", eval('[1,2].then {"#@1#@2"}'))
|
||||
assert_equal(3, eval('->{@1+@2}.call(1,2)'))
|
||||
assert_equal(4, eval('->(a=->{@1}){a}.call.call(4)'))
|
||||
assert_equal(5, eval('-> a: ->{@1} {a}.call.call(5)'))
|
||||
assert_syntax_error('proc {|| @1}', /ordinary parameter is defined/)
|
||||
assert_syntax_error('proc {|;a| @1}', /ordinary parameter is defined/)
|
||||
assert_syntax_error("proc {|\n| @1}", /ordinary parameter is defined/)
|
||||
|
|
Loading…
Add table
Reference in a new issue