summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorShugo Maeda <shugo@ruby-lang.org>2021-09-11 18:49:12 +0900
committerShugo Maeda <shugo@ruby-lang.org>2021-09-11 18:52:25 +0900
commitc60dbcd1c55cd77a24c41d5e1a9555622be8b2b8 (patch)
tree318d03414f630b0d31cbaf48a740965af4dd4615 /parse.y
parent64e056a4c5d4595cd2c36aabc747cca32f4b5395 (diff)
Allow value omission in Hash literals
`{x:, y:}` is a syntax sugar of `{x: x, y: y}`.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y9
1 files changed, 9 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 8017011bb79..d4443d50d25 100644
--- a/parse.y
+++ b/parse.y
@@ -5617,6 +5617,15 @@ assoc : arg_value tASSOC arg_value
/*% %*/
/*% ripper: assoc_new!($1, $2) %*/
}
+ | tLABEL
+ {
+ /*%%%*/
+ NODE *val = gettable(p, $1, &@$);
+ if (!val) val = NEW_BEGIN(0, &@$);
+ $$ = list_append(p, NEW_LIST(NEW_LIT(ID2SYM($1), &@1), &@$), val);
+ /*% %*/
+ /*% ripper: assoc_new!($1, id_is_var(p, get_id($1)) ? var_ref!($1) : vcall!($1)) %*/
+ }
| tSTRING_BEG string_contents tLABEL_END arg_value
{
/*%%%*/