diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-05 08:42:13 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:44 +0000 |
| commit | 2cb75b8f1760a9aefb2221c4a6fab9304bdb3da2 (patch) | |
| tree | 96f85e2c26421ffa16726085cef6c3bbebd752cb /lib | |
| parent | fabece2507c12f131c67d2324c1aee27ab8a5f7d (diff) | |
[ruby/prism] Implement multi target nodes for ripper translation
https://github.com/ruby/prism/commit/ceb5a5cf62
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/translation/ripper.rb | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index 6eb65b14ae..adc82406fa 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -1571,10 +1571,28 @@ module Prism on_module(constant_path, bodystmt) end - # foo, bar = baz - # ^^^^^^^^ + # (foo, bar), bar = qux + # ^^^^^^^^^^ def visit_multi_target_node(node) - raise NoMethodError, __method__ + bounds(node.location) + targets = + [*node.lefts, *node.rest, *node.rights].inject(on_mlhs_new) do |mlhs, target| + bounds(target.location) + + if target.is_a?(ImplicitRestNode) + on_excessed_comma # these do not get put into the targets + mlhs + else + on_mlhs_add(mlhs, visit(target)) + end + end + + if node.lparen_loc.nil? + targets + else + bounds(node.lparen_loc) + on_mlhs_paren(targets) + end end # foo, bar = baz |
