separate hash literal and keyword arguments
* compile.c (compile_array_keyword_arg): separate keyword splat inside hash literal from argument list. * parse.y (rparen): flag hash literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
28c02b9e08
commit
03a2862b98
@ -3053,7 +3053,7 @@ compile_array_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
|
||||
|
||||
assert(nd_type(node) == NODE_ARRAY);
|
||||
if (!key_node) {
|
||||
if (flag) *flag |= VM_CALL_KW_SPLAT;
|
||||
if (flag && !root_node->nd_alen) *flag |= VM_CALL_KW_SPLAT;
|
||||
return FALSE;
|
||||
}
|
||||
else if (nd_type(key_node) == NODE_LIT && RB_TYPE_P(key_node->nd_lit, T_SYMBOL)) {
|
||||
|
13
node.c
13
node.c
@ -545,9 +545,16 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
|
||||
break;
|
||||
|
||||
case NODE_HASH:
|
||||
ANN("hash constructor");
|
||||
ANN("format: { [nd_head] }");
|
||||
ANN("example: { 1 => 2, 3 => 4 }");
|
||||
if (!node->nd_alen) {
|
||||
ANN("keyword arguments");
|
||||
ANN("format: nd_head");
|
||||
ANN("example: a: 1, b: 2");
|
||||
}
|
||||
else {
|
||||
ANN("hash constructor");
|
||||
ANN("format: { [nd_head] }");
|
||||
ANN("example: { 1 => 2, 3 => 4 }");
|
||||
}
|
||||
LAST_NODE;
|
||||
F_NODE(nd_head, "contents");
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user