diff options
author | Kevin Newton <kddnewton@gmail.com> | 2024-03-05 23:58:27 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:57 +0000 |
commit | dad21783ac1bb7de4138bc18f93507abc64b2a0b (patch) | |
tree | d83a833140bc30bc19f00b9f17d0bc8d56b62b02 /lib/prism/translation/ripper.rb | |
parent | 2a051b0140e538b20b38b2e23222de22dd588c05 (diff) |
[ruby/prism] Better handle hash pattern in ripper translation
https://github.com/ruby/prism/commit/4639803277
Diffstat (limited to 'lib/prism/translation/ripper.rb')
-rw-r--r-- | lib/prism/translation/ripper.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index bb5b2c6003..addeb38fdd 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -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) |