1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Disallow numbered parameter as the default value of optional argument

[Fix GH-2139] [Bug #15783]
This commit is contained in:
Seiei Miyagi 2019-04-23 00:21:50 +09:00 committed by Nobuyoshi Nakada
parent ae07b66aaa
commit 6ca9e7cc07
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 2 additions and 0 deletions

View file

@ -4735,6 +4735,7 @@ f_norm_arg : f_bad_arg
| tIDENTIFIER
{
formal_argument(p, get_id($1));
p->max_numparam = -1;
$$ = $1;
}
;

View file

@ -1302,6 +1302,7 @@ eom
assert_syntax_error('->(x){@1}', /ordinary parameter is defined/)
assert_syntax_error('->x{@1}', /ordinary parameter is defined/)
assert_syntax_error('->x:@2{}', /ordinary parameter is defined/)
assert_syntax_error('->x=@1{}', /ordinary parameter is defined/)
assert_syntax_error('proc {@1 = nil}', /Can't assign to numbered parameter @1/)
assert_syntax_error('proc {@01}', /leading zero/)
assert_syntax_error('proc {@1_}', /unexpected/)