diff --git a/compile.c b/compile.c index 99e00b4e6a..170bb99776 100644 --- a/compile.c +++ b/compile.c @@ -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)) { diff --git a/node.c b/node.c index f6d551a106..0222a19af1 100644 --- a/node.c +++ b/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; diff --git a/parse.y b/parse.y index c12b80cc06..0fb5605345 100644 --- a/parse.y +++ b/parse.y @@ -2546,6 +2546,7 @@ primary : literal { /*%%%*/ $$ = new_hash($2); + $$->nd_alen = TRUE; /*% $$ = dispatch1(hash, escape_Qundef($2)); %*/