From c60dbcd1c55cd77a24c41d5e1a9555622be8b2b8 Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Sat, 11 Sep 2021 18:49:12 +0900 Subject: Allow value omission in Hash literals `{x:, y:}` is a syntax sugar of `{x: x, y: y}`. --- parse.y | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 8017011bb7..d4443d50d2 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 { /*%%%*/ -- cgit v1.2.3