[ruby/prism] Better handle hash pattern in ripper translation

4639803277
This commit is contained in:
Kevin Newton 2024-03-05 23:58:27 -05:00 committed by git
parent 2a051b0140
commit dad21783ac
2 changed files with 18 additions and 9 deletions

View file

@ -1384,17 +1384,29 @@ module Prism
elements =
if node.elements.any? || !node.rest.nil?
node.elements.map do |element|
bounds(element.key.location)
key = on_label(element.key.slice)
value = visit(element.value)
[key, value]
[
if (key = element.key).opening_loc.nil?
visit(key)
else
bounds(key.value_loc)
if (value = key.value).empty?
on_string_content
else
on_string_add(on_string_content, on_tstring_content(value))
end
end,
visit(element.value)
]
end
end
rest =
if !node.rest.nil?
case node.rest
when AssocSplatNode
visit(node.rest.value)
when NoKeywordsParameterNode
bounds(node.rest.location)
on_var_field(:nil)
end
bounds(node.location)

View file

@ -58,7 +58,6 @@ module Prism
seattlerb/call_array_lambda_block_call.txt
seattlerb/call_assoc_trailing_comma.txt
seattlerb/call_trailing_comma.txt
seattlerb/case_in.txt
seattlerb/defn_oneliner_eq2.txt
seattlerb/defs_oneliner_eq2.txt
seattlerb/difficult3_5.txt
@ -86,7 +85,6 @@ module Prism
seattlerb/parse_opt_call_args_lit_comma.txt
seattlerb/parse_pattern_051.txt
seattlerb/parse_pattern_058.txt
seattlerb/parse_pattern_076.txt
seattlerb/return_call_assocs.txt
seattlerb/stabby_block_iter_call.txt
seattlerb/stabby_block_iter_call_no_target_with_arg.txt
@ -135,7 +133,6 @@ module Prism
whitequark/masgn_attr.txt
whitequark/masgn_nested.txt
whitequark/masgn_splat.txt
whitequark/newline_in_hash_argument.txt
whitequark/numbered_args_after_27.txt
whitequark/parser_bug_640.txt
whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt