summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-08-20 12:28:04 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-30 12:39:31 -0700
commit42adc5bc6bb532e20bf2191ad99781ee701dea36 (patch)
tree3764db7c0d78947b9e7c651f0c62937e41317666
parenta810f6cbefb5726c626b0c490522865588f4480e (diff)
Add back missing warning for duplicate keys in splatted hashes
This reverts the changes to parse.y in a5b37262524ac39d2af13eea174486370a581c23 as they are not actually needed and cause the warning for duplicate hash keys to not be emitted.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2395
-rw-r--r--parse.y12
1 files changed, 11 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index c575dfdded..ba43053a86 100644
--- a/parse.y
+++ b/parse.y
@@ -5151,6 +5151,12 @@ assocs : assoc
assocs = tail;
}
else if (tail) {
+ if (assocs->nd_head &&
+ !tail->nd_head && nd_type(tail->nd_next) == NODE_ARRAY &&
+ nd_type(tail->nd_next->nd_head) == NODE_HASH) {
+ /* DSTAR */
+ tail = tail->nd_next->nd_head->nd_head;
+ }
assocs = list_concat(assocs, tail);
}
$$ = assocs;
@@ -5188,7 +5194,11 @@ assoc : arg_value tASSOC arg_value
| tDSTAR arg_value
{
/*%%%*/
- $$ = list_append(p, NEW_LIST(0, &@$), $2);
+ if (nd_type($2) == NODE_HASH &&
+ !($2->nd_head && $2->nd_head->nd_alen))
+ $$ = 0;
+ else
+ $$ = list_append(p, NEW_LIST(0, &@$), $2);
/*% %*/
/*% ripper: assoc_splat!($2) %*/
}