diff options
author | Kevin Newton <kddnewton@gmail.com> | 2024-03-06 00:46:34 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:59 +0000 |
commit | f75aa767f75a0ed8c10af31d07f2db875d26d420 (patch) | |
tree | 0a3755804afeaf1c2503fb879ce2859887b9d247 /lib | |
parent | cdb47b1b3a641cc86092c2a60070752e10e873e8 (diff) |
[ruby/prism] Better handle splat in MRHS
https://github.com/ruby/prism/commit/8331874218
Diffstat (limited to 'lib')
-rw-r--r-- | lib/prism/translation/ripper.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index 79eaac3bd0..97274cabf9 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -2812,13 +2812,14 @@ module Prism length = elements.length bounds(elements.first.location) - elements.each_with_index.inject(on_args_new) do |args, (element, index)| + elements.each_with_index.inject((elements.first.is_a?(SplatNode) && length == 1) ? on_mrhs_new : on_args_new) do |args, (element, index)| arg = visit(element) bounds(element.location) if index == length - 1 if element.is_a?(SplatNode) - on_mrhs_add_star(on_mrhs_new_from_args(args), arg) + mrhs = index == 0 ? args : on_mrhs_new_from_args(args) + on_mrhs_add_star(mrhs, arg) else on_mrhs_add(on_mrhs_new_from_args(args), arg) end |