Permalink
Browse files

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent d6a977f commit 8fe3fb4c0f69535b302e124f3afc58dce4be5dbb @nobu nobu committed Mar 13, 2012
Showing with 177 additions and 644 deletions.
  1. +11 −0 ChangeLog
  2. +17 −11 compile.c
  3. +1 −0 node.c
  4. +140 −630 parse.y
  5. +7 −2 test/ruby/test_syntax.rb
  6. +1 −1 vm_insnhelper.c
View
@@ -1,3 +1,14 @@
+Tue Mar 13 22:00:14 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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 <nobu@ruby-lang.org>
* parse.y (block_param, f_args): add rules for the case arguments
View
@@ -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;
}
@@ -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);
View
1 node.c
@@ -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:
Oops, something went wrong.

0 comments on commit 8fe3fb4

Please sign in to comment.