Fix a case where numbered parameters should not be allowed

Because `proc{|| @1}` is a syntax error, the following should
also be syntax errors:

```ruby
proc { |
| @1}
```

```ruby
proc { |; a| @1 }
```

This fixes both cases.

[Bug #15825]
This commit is contained in:
Jeremy Evans 2019-05-04 21:33:58 -07:00 committed by Nobuyoshi Nakada
parent 374c8f4eba
commit b8f3be295b
No known key found for this signature in database
GPG Key ID: 4BC7D6DF58D8DF60
2 changed files with 3 additions and 0 deletions

View File

@ -3307,6 +3307,7 @@ opt_block_param : none
block_param_def : '|' opt_bv_decl '|'
{
p->cur_arg = 0;
p->max_numparam = -1;
/*%%%*/
$$ = 0;
/*% %*/

View File

@ -1313,6 +1313,8 @@ eom
assert_equal("12", eval('[1,2].then {"#@1#@2"}'))
assert_equal(3, eval('->{@1+@2}.call(1,2)'))
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/)
assert_syntax_error('proc {|x| @1}', /ordinary parameter is defined/)
assert_syntax_error('->(){@1}', /ordinary parameter is defined/)
assert_syntax_error('->(x){@1}', /ordinary parameter is defined/)