diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-12 11:10:22 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-12 11:10:22 +0000 |
commit | ead9b197be96f9eacf462b5539f71c43422495d0 (patch) | |
tree | 9b2965a14b6226ab54d0d2a8ad2a6f831454367f /parse.y | |
parent | 56b42dec015337f6a1a30aee1a6e6364ded3e468 (diff) | |
download | ruby-ead9b197be96f9eacf462b5539f71c43422495d0.tar.gz |
* parse.y (f_args): allow post mandatory arguments after optional
arguments. [ruby-dev:29014]
* parse.y (new_args_gen): allow post_args without rest_args.
* eval.c (formal_assign): ditto.
* parse.y (new_args_gen): check post argument duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -3941,6 +3941,14 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg $$ = dispatch5(params, $1, $3, Qnil, Qnil, escape_Qundef($4)); %*/ } + | f_arg ',' f_optarg ',' f_post_arg opt_f_block_arg + { + /*%%%*/ + $$ = new_args($1, $3, 0, $5, $6); + /*% + $$ = dispatch5(params, $1, $3, Qnil, $5, escape_Qundef($6)); + %*/ + } | f_arg ',' f_rest_arg opt_f_block_arg { /*%%%*/ @@ -3989,6 +3997,14 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg $$ = dispatch5(params, Qnil, $1, Qnil, Qnil, escape_Qundef($2)); %*/ } + | f_optarg ',' f_post_arg opt_f_block_arg + { + /*%%%*/ + $$ = new_args(0, $1, 0, $3, $4); + /*% + $$ = dispatch5(params, Qnil, $1, Qnil, $3, escape_Qundef($4)); + %*/ + } | f_rest_arg opt_f_block_arg { /*%%%*/ @@ -4089,7 +4105,7 @@ f_arg : f_norm_arg VALUE arg = ID2SYM($3); $$ = $1; if (rb_ary_includes($$, arg)) { - yyerror("duplicated argument arg"); + yyerror("duplicated argument name"); } rb_ary_push($$, arg); /*% @@ -7898,9 +7914,18 @@ new_args_gen(struct parser_params *parser, VALUE m, NODE *o, NODE *r, NODE *p, N yyerror("duplicated rest argument name"); return 0; } - if (p) { - r = NEW_POSTARG(r, p); + } + if (p) { + node = p; + while (node) { + if (!node->nd_head) break; + if (arg_dup_check(node->nd_head->nd_vid, m, list, node)) { + yyerror("duplicated argument name"); + return 0; + } + node = node->nd_next; } + r = NEW_POSTARG(r, p); } node = NEW_ARGS(m, o, r); if (b) { |