1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Hash values should be omitted in Ripper results

This commit is contained in:
Shugo Maeda 2021-09-11 22:03:10 +09:00
parent 8d0315a2bb
commit 7686776c05
No known key found for this signature in database
GPG key ID: 2DFE34085E97CE47
2 changed files with 15 additions and 1 deletions

View file

@ -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
{

View file

@ -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