Skip to content

Commit

Permalink
+ ruby33.y: allow semicolon in parenthesis at the first argument of c…
Browse files Browse the repository at this point in the history
…ommand call (#971)
  • Loading branch information
iliabylich committed Dec 28, 2023
1 parent 535a9b8 commit 4a11479
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/parser/ruby33.y
Original file line number Diff line number Diff line change
Expand Up @@ -1207,22 +1207,14 @@ rule
result = @builder.begin_keyword(val[0], val[2], val[3])
}
| tLPAREN_ARG stmt
| tLPAREN_ARG compstmt
{
@lexer.state = :expr_endarg
}
rparen
tRPAREN
{
result = @builder.begin(val[0], val[1], val[3])
}
| tLPAREN_ARG
{
@lexer.state = :expr_endarg
}
opt_nl tRPAREN
{
result = @builder.begin(val[0], nil, val[3])
}
| tLPAREN compstmt tRPAREN
{
result = @builder.begin(val[0], val[1], val[2])
Expand Down
48 changes: 48 additions & 0 deletions test/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11322,4 +11322,52 @@ def test_ruby_bug_18878
%q{},
SINCE_3_3)
end

def test_ruby_bug_19281
assert_parses(
s(:send, nil, :p,
s(:begin,
s(:int, 1),
s(:int, 2)),
s(:begin,
s(:int, 3)),
s(:begin,
s(:int, 4))),
'p (1;2),(3),(4)',
%q{},
SINCE_3_3)

assert_parses(
s(:send, nil, :p,
s(:begin),
s(:begin),
s(:begin)),
'p (;),(),()',
%q{},
SINCE_3_3)

assert_parses(
s(:send,
s(:send, nil, :a), :b,
s(:begin,
s(:int, 1),
s(:int, 2)),
s(:begin,
s(:int, 3)),
s(:begin,
s(:int, 4))),
'a.b (1;2),(3),(4)',
%q{},
SINCE_3_3)

assert_parses(
s(:send,
s(:send, nil, :a), :b,
s(:begin),
s(:begin),
s(:begin)),
'a.b (;),(),()',
%q{},
SINCE_3_3)
end
end

0 comments on commit 4a11479

Please sign in to comment.