зеркало из https://github.com/github/ruby.git
Disallow numbered parameter as the default value of optional argument
[Fix GH-2139] [Bug #15783]
This commit is contained in:
Родитель
ae07b66aaa
Коммит
6ca9e7cc07
1
parse.y
1
parse.y
|
@ -4735,6 +4735,7 @@ f_norm_arg : f_bad_arg
|
||||||
| tIDENTIFIER
|
| tIDENTIFIER
|
||||||
{
|
{
|
||||||
formal_argument(p, get_id($1));
|
formal_argument(p, get_id($1));
|
||||||
|
p->max_numparam = -1;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
|
@ -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{@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:@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 {@1 = nil}', /Can't assign to numbered parameter @1/)
|
||||||
assert_syntax_error('proc {@01}', /leading zero/)
|
assert_syntax_error('proc {@01}', /leading zero/)
|
||||||
assert_syntax_error('proc {@1_}', /unexpected/)
|
assert_syntax_error('proc {@1_}', /unexpected/)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче