Skip to content

Commit

Permalink
- find_pat mid-patterns are now splatted inline, not wrapped in an ar…
Browse files Browse the repository at this point in the history
…ray_pat.

They were wrapped in a mis-shapen array_pat, so I got rid of it while
I was in there.

[git-p4: depot-paths = "//src/ruby_parser/dev/": change = 13504]
  • Loading branch information
zenspider committed Jul 17, 2022
1 parent d9d4b65 commit 8553cf6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/ruby_parser_extras.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,9 @@ def new_find_pattern_tail lhs, mid, rhs
lhs_id = "*#{lhs_id}".to_sym
rhs_id = "*#{rhs_id}".to_sym

mid.sexp_type = :array_pat # HACK?
raise "BAD?" unless mid.sexp_type == :array_TAIL

s(:find_pat_TAIL, lhs_id, mid, rhs_id).line line
s(:find_pat_TAIL, lhs_id, *mid.sexp_body, rhs_id).line line
end

def new_for expr, var, body
Expand Down
8 changes: 4 additions & 4 deletions test/test_ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5085,15 +5085,15 @@ def test_case_in_20
s(:find_pat,
s(:const, :Symbol).line(2),
:"*lhs",
s(:array_pat, s(:lasgn, :x).line(2)).line(2),
s(:lasgn, :x).line(2),
:"*rhs").line(2))
end

def test_case_in_22
assert_case_in("Symbol[*lhs, x, *rhs]",
s(:find_pat, s(:const, :Symbol).line(2),
:"*lhs",
s(:array_pat, s(:lasgn, :x).line(2)).line(2),
s(:lasgn, :x).line(2),
:"*rhs").line(2))
end
end
Expand Down Expand Up @@ -5221,7 +5221,7 @@ def test_case_in_find
s(:in,
s(:find_pat, nil,
:"*a",
s(:array_pat, s(:lit, :+).line(2)).line(2),
s(:lit, :+).line(2),
:"*b").line(2),
nil).line(2),
nil)
Expand All @@ -5236,7 +5236,7 @@ def test_case_in_find_array
s(:in,
s(:find_pat, nil,
:*,
s(:array_pat, s(:lit, :b).line(2), s(:lasgn, :c).line(2)).line(2),
s(:lit, :b).line(2), s(:lasgn, :c).line(2),
:*).line(2),
nil).line(2),
nil)
Expand Down

0 comments on commit 8553cf6

Please sign in to comment.