Skip to content

Commit

Permalink
Better handle splats in MRHS in rescues in ripper translation
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Mar 6, 2024
1 parent 76cf29e commit 36a0b2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 13 additions & 3 deletions lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2318,12 +2318,22 @@ def visit_rescue_node(node)

node.exceptions.each_with_index.inject(on_args_new) do |mrhs, (exception, index)|
arg = visit(exception)

bounds(exception.location)
mrhs = on_mrhs_new_from_args(mrhs) if index == length - 1

if index == length - 1
on_mrhs_add(on_mrhs_new_from_args(mrhs), arg)
if exception.is_a?(SplatNode)
if index == length - 1
on_mrhs_add_star(mrhs, arg)
else
on_args_add_star(mrhs, arg)
end
else
on_args_add(mrhs, arg)
if index == length - 1
on_mrhs_add(mrhs, arg)
else
on_args_add(mrhs, arg)
end
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions test/prism/ripper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class RipperTest < TestCase
seattlerb/block_call_dot_op2_brace_block.txt
seattlerb/block_command_operation_colon.txt
seattlerb/block_command_operation_dot.txt
unparser/corpus/literal/block.txt
unparser/corpus/literal/kwbegin.txt
whitequark/send_block_chain_cmd.txt
]

Expand Down

0 comments on commit 36a0b2e

Please sign in to comment.