Skip to content

Commit

Permalink
Merge pull request #68 from mvz/compatible-rescue-with-multiple-assig…
Browse files Browse the repository at this point in the history
…nment

Handle multiple assignment with RHS that is a block
  • Loading branch information
mvz authored Mar 23, 2019
2 parents fba6b06 + 90a72ac commit 7fbe607
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ripper_ruby_parser/sexp_handlers/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def process_massign(exp)
when :mrhs
_, right = right
else
right = s(:to_ary, right)
right = s(:to_ary, unwrap_begin(right))
end

s(:masgn, left, right)
Expand Down
2 changes: 1 addition & 1 deletion lib/ripper_ruby_parser/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RipperRubyParser
VERSION = '1.5.1'
VERSION = '1.6.0.pre1'
end
7 changes: 7 additions & 0 deletions test/ripper_ruby_parser/sexp_handlers/assignment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,13 @@
s(:to_ary, s(:call, nil, :baz)))
end

it 'works with blocks' do
'foo, bar = begin; baz; end'.
must_be_parsed_as s(:masgn,
s(:array, s(:lasgn, :foo), s(:lasgn, :bar)),
s(:to_ary, s(:call, nil, :baz)))
end

it 'works with a rescue modifier' do
'foo, bar = baz rescue qux'.
must_be_parsed_as s(:rescue,
Expand Down
7 changes: 7 additions & 0 deletions test/samples/misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ def barfoo
puts err
end

# begin/rescue with multiple assignment
foo, bar = begin
baz
rescue qux
quuz
end

# alias
alias foo bar
alias :foo bar
Expand Down

0 comments on commit 7fbe607

Please sign in to comment.