mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
parse.y: optional arguments in rhs
* parse.y (f_arg_asgn): define optional arguments as argument variables in the rhs default expressions. [ruby-core:61299] [Bug #9593] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
89e70fe8e7
commit
01740f0c27
3 changed files with 40 additions and 6 deletions
16
parse.y
16
parse.y
|
@ -784,7 +784,7 @@ static void token_info_pop(struct parser_params*, const char *token);
|
|||
%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
|
||||
%type <id> fsym keyword_variable user_variable sym symbol operation operation2 operation3
|
||||
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
|
||||
%type <id> f_kwrest f_label
|
||||
%type <id> f_kwrest f_label f_arg_asgn
|
||||
/*%%%*/
|
||||
/*%
|
||||
%type <val> program reswords then do dot_or_colon
|
||||
|
@ -4548,9 +4548,15 @@ f_norm_arg : f_bad_arg
|
|||
}
|
||||
;
|
||||
|
||||
f_arg_item : f_norm_arg
|
||||
f_arg_asgn : f_norm_arg
|
||||
{
|
||||
arg_var(get_id($1));
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
f_arg_item : f_arg_asgn
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = NEW_ARGS_AUX($1, 1);
|
||||
/*%
|
||||
|
@ -4708,9 +4714,8 @@ f_kwrest : kwrest_mark tIDENTIFIER
|
|||
}
|
||||
;
|
||||
|
||||
f_opt : f_norm_arg '=' arg_value
|
||||
f_opt : f_arg_asgn '=' arg_value
|
||||
{
|
||||
arg_var(get_id($1));
|
||||
$$ = assignable($1, $3);
|
||||
/*%%%*/
|
||||
$$ = NEW_OPT_ARG(0, $$);
|
||||
|
@ -4720,9 +4725,8 @@ f_opt : f_norm_arg '=' arg_value
|
|||
}
|
||||
;
|
||||
|
||||
f_block_opt : f_norm_arg '=' primary_value
|
||||
f_block_opt : f_arg_asgn '=' primary_value
|
||||
{
|
||||
arg_var(get_id($1));
|
||||
$$ = assignable($1, $3);
|
||||
/*%%%*/
|
||||
$$ = NEW_OPT_ARG(0, $$);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue