1
0
Fork 0
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:
Jeremy Evans 2019-05-04 21:43:22 -07:00 committed by Nobuyoshi Nakada
parent b8f3be295b
commit 0c0ed1cee8
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -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/)