ruby-changes:50667
From: nobu <ko1@a...>
Date: Mon, 19 Mar 2018 12:16:44 +0900 (JST)
Subject: [ruby-changes:50667] nobu:r62832 (trunk): parse.y: fix duplicate kwrest
nobu 2018-03-19 12:16:40 +0900 (Mon, 19 Mar 2018) New Revision: 62832 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62832 Log: parse.y: fix duplicate kwrest * parse.y (f_kwrest): add the variable name as an argument, as well as an internal variable. * parse.y (new_args_tail): now keyword rest argument variable is always placed between keyword arguments and block argument, so so just reorder required and optional keyword arguments. no longer kwrest duplicates. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 62831) +++ parse.y (revision 62832) @@ -4053,7 +4053,7 @@ kwrest_mark : tPOW https://github.com/ruby/ruby/blob/trunk/parse.y#L4053 f_kwrest : kwrest_mark tIDENTIFIER { - shadowing_lvar(p, get_id($2)); + arg_var(p, shadowing_lvar(p, get_id($2))); /*%%%*/ $$ = $2; /*% %*/ @@ -9919,8 +9919,11 @@ new_args_tail(struct parser_params *p, N https://github.com/ruby/ruby/blob/trunk/parse.y#L9919 } kw_bits = internal_id(p); - if (kw_rest_arg && is_junk_id(kw_rest_arg)) vtable_pop(p->lvtbl->args, 1); - vtable_pop(p->lvtbl->args, vtable_size(required_kw_vars) + vtable_size(kw_vars) + (block != 0)); + + /* reorder */ + vtable_pop(p->lvtbl->args, + vtable_size(required_kw_vars) + vtable_size(kw_vars) + + (block != 0) + (kw_rest_arg != 0)); for (i=0; i<vtable_size(required_kw_vars); i++) arg_var(p, required_kw_vars->tbl[i]); for (i=0; i<vtable_size(kw_vars); i++) arg_var(p, kw_vars->tbl[i]); @@ -9935,9 +9938,6 @@ new_args_tail(struct parser_params *p, N https://github.com/ruby/ruby/blob/trunk/parse.y#L9938 args->kw_rest_arg->nd_cflag = kw_bits; } else if (kw_rest_arg) { - if (block) vtable_pop(p->lvtbl->args, 1); /* reorder */ - arg_var(p, kw_rest_arg); - if (block) arg_var(p, block); args->kw_rest_arg = NEW_DVAR(kw_rest_arg, loc); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/