diff options
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ripper/test_sexp.rb | 14 |
2 files changed, 15 insertions, 1 deletions
@@ -5624,7 +5624,7 @@ assoc : arg_value tASSOC arg_value 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)) %*/ + /*% ripper: assoc_new!($1, Qnil) %*/ } | tSTRING_BEG string_contents tLABEL_END arg_value { diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb index b4e70fa4f5..9faeaba782 100644 --- a/test/ripper/test_sexp.rb +++ b/test/ripper/test_sexp.rb @@ -520,4 +520,18 @@ eot assert_raise(SyntaxError) { Ripper.sexp('def req(true) end', raise_errors: true) } assert_raise(SyntaxError) { Ripper.sexp_raw('def req(true) end', raise_errors: true) } end + + def test_hash_value_omission + sexp = Ripper.sexp("{x: 1, y:}") + assoclist = search_sexp(:assoclist_from_args, sexp) + x = assoclist[1][0] + assert_equal(:@label, x[1][0]) + assert_equal("x:", x[1][1]) + assert_equal(:@int, x[2][0]) + assert_equal("1", x[2][1]) + y = assoclist[1][1] + assert_equal(:@label, y[1][0]) + assert_equal("y:", y[1][1]) + assert_equal(nil, y[2]) + end end if ripper_test |