mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Arguments forwarding is not allowed in lambda [Feature #16253]
This commit is contained in:
parent
1fb4584825
commit
6279e45cde
2 changed files with 15 additions and 11 deletions
24
parse.y
24
parse.y
|
@ -4781,6 +4781,19 @@ f_arglist : '(' f_args rparen
|
|||
SET_LEX_STATE(EXPR_BEG);
|
||||
p->command_start = TRUE;
|
||||
}
|
||||
| '(' args_forward rparen
|
||||
{
|
||||
arg_var(p, idFWD_REST);
|
||||
arg_var(p, idFWD_KWREST);
|
||||
arg_var(p, idFWD_BLOCK);
|
||||
/*%%%*/
|
||||
$$ = new_args_tail(p, Qnone, idFWD_KWREST, idFWD_BLOCK, &@2);
|
||||
$$ = new_args(p, Qnone, Qnone, idFWD_REST, Qnone, $$, &@2);
|
||||
/*% %*/
|
||||
/*% ripper: paren!(params_new(Qnone, Qnone, $2, Qnone, Qnone, Qnone, Qnone)) %*/
|
||||
SET_LEX_STATE(EXPR_BEG);
|
||||
p->command_start = TRUE;
|
||||
}
|
||||
| {
|
||||
$<num>$ = p->in_kwarg;
|
||||
p->in_kwarg = 1;
|
||||
|
@ -4883,17 +4896,6 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail
|
|||
{
|
||||
$$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $1, &@$);
|
||||
}
|
||||
| args_forward
|
||||
{
|
||||
arg_var(p, idFWD_REST);
|
||||
arg_var(p, idFWD_KWREST);
|
||||
arg_var(p, idFWD_BLOCK);
|
||||
/*%%%*/
|
||||
$$ = new_args_tail(p, Qnone, idFWD_KWREST, idFWD_BLOCK, &@1);
|
||||
$$ = new_args(p, Qnone, Qnone, idFWD_REST, Qnone, $$, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: params_new(Qnone, Qnone, $1, Qnone, Qnone, Qnone, Qnone) %*/
|
||||
}
|
||||
| /* none */
|
||||
{
|
||||
$$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
|
||||
|
|
|
@ -1476,6 +1476,8 @@ eom
|
|||
assert_valid_syntax('def foo(...) end')
|
||||
assert_syntax_error('iter do |...| end', /unexpected/)
|
||||
assert_syntax_error('iter {|...|}', /unexpected/)
|
||||
assert_syntax_error('->... {}', /unexpected/)
|
||||
assert_syntax_error('->(...) {}', /unexpected/)
|
||||
assert_syntax_error('def foo(x, y, z) bar(...); end', /unexpected/)
|
||||
assert_syntax_error('def foo(x, y, z) super(...); end', /unexpected/)
|
||||
assert_syntax_error('def foo(...) yield(...); end', /unexpected/)
|
||||
|
|
Loading…
Reference in a new issue