Skip to content

Commit

Permalink
* compile.c (iseq_set_arguments): keyword rest arg without keyword args.
Browse files Browse the repository at this point in the history
* node.c (dump_node): dump kw_rest_arg too.
* parse.y (block_param, f_arg): more kwrest patterns.
  [ruby-core:42455][Bug ruby#5989]
* parse.y (new_args_gen): no extra kw_rest_arg if no keyword rest arg.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Mar 13, 2012
1 parent d6a977f commit 8fe3fb4
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 644 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Tue Mar 13 22:00:14 2012 Nobuyoshi Nakada <[email protected]>

* compile.c (iseq_set_arguments): keyword rest arg without keyword args.

* node.c (dump_node): dump kw_rest_arg too.

* parse.y (block_param, f_arg): more kwrest patterns.
[ruby-core:42455][Bug #5989]

* parse.y (new_args_gen): no extra kw_rest_arg if no keyword rest arg.

Tue Mar 13 15:17:03 2012 Nobuyoshi Nakada <[email protected]>

* parse.y (block_param, f_args): add rules for the case arguments
Expand Down
28 changes: 17 additions & 11 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,12 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
}
ADD_INSN(optargs, nd_line(args->kw_args), pop);
}
else if (args->kw_rest_arg) {
iseq->arg_keyword = get_dyna_var_idx_at_raw(iseq, args->kw_rest_arg->nd_vid);
COMPILE(optargs, "kwarg", args->kw_rest_arg);
iseq->arg_keyword_check = (args->kw_rest_arg->nd_vid & ID_SCOPE_MASK) == ID_JUNK;
ADD_INSN(optargs, nd_line(args->kw_rest_arg), pop);
}
else {
iseq->arg_keyword = -1;
}
Expand Down Expand Up @@ -4992,17 +4998,17 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(id));
ADD_SEND(ret, nd_line(node), ID2SYM(rb_intern("delete")), INT2FIX(1));
switch (nd_type(node->nd_body)) {
case NODE_LASGN:
idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
ADD_INSN1(ret, nd_line(node), setlocal, INT2FIX(idx));
break;
case NODE_DASGN:
case NODE_DASGN_CURR:
idx = get_dyna_var_idx(iseq, id, &lv, &ls);
ADD_INSN2(ret, nd_line(node), setdynamic, INT2FIX(ls - idx), INT2FIX(lv));
break;
default:
rb_bug("iseq_compile_each (NODE_KW_ARG): unknown node: %s", ruby_node_name(nd_type(node->nd_body)));
case NODE_LASGN:
idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
ADD_INSN1(ret, nd_line(node), setlocal, INT2FIX(idx));
break;
case NODE_DASGN:
case NODE_DASGN_CURR:
idx = get_dyna_var_idx(iseq, id, &lv, &ls);
ADD_INSN2(ret, nd_line(node), setdynamic, INT2FIX(ls - idx), INT2FIX(lv));
break;
default:
rb_bug("iseq_compile_each (NODE_KW_ARG): unknown node: %s", ruby_node_name(nd_type(node->nd_body)));
}
ADD_INSNL(ret, nd_line(node), jump, end_label);
ADD_LABEL(ret, default_label);
Expand Down
1 change: 1 addition & 0 deletions node.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
F_NODE(nd_ainfo->opt_args, "optional arguments");
LAST_NODE;
F_NODE(nd_ainfo->kw_args, "keyword arguments");
F_NODE(nd_ainfo->kw_rest_arg, "keyword rest argument");
break;

case NODE_SCOPE:
Expand Down
Loading

0 comments on commit 8fe3fb4

Please sign in to comment.